This file is indexed.

/usr/share/perl5/Data/Faker/DateTime.pm is in libdata-faker-perl 0.10-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
package Data::Faker::DateTime;
use strict;
use warnings;
use vars qw($VERSION); $VERSION = '0.10';
use base 'Data::Faker';
use POSIX;

=head1 NAME

Data::Faker::DateTime - Data::Faker plugin

=head1 SYNOPSIS AND USAGE

See L<Data::Faker>

=head1 DATA PROVIDERS

=over 4

=item unixtime

Return a unix time (seconds since the epoch) for a random time between the
epoch and now.

=cut

__PACKAGE__->register_plugin('unixtime' => sub { int(rand(time())) });

=item date

Return a random date as a string, using a random date format (see date_format).

=cut

__PACKAGE__->register_plugin(
	'date' => sub { timestr(shift()->date_format) },
);

=item time

Return a random time as a string, using a random time format (see time_format).

=cut

__PACKAGE__->register_plugin(
	'time' => sub { timestr(shift()->time_format) },
);

=item rfc822

Return an RFC 822 formatted random date.  This method may not work on systems
using a non-GNU strftime implementation (kindly let me know if that is the
case.)

=cut

__PACKAGE__->register_plugin(
	'rfc822' => sub { timestr('%a,  %d  %b  %Y  %H:%M:%S  %z') },
);

=item ampm

Returns am or pm randomly (in the current locale) using one of the formats
specified in ampm_format.

=cut

__PACKAGE__->register_plugin(
	'ampm' => sub { timestr(shift()->ampm_format) },
);

=item time_format

Return a random time format.

=cut

__PACKAGE__->register_plugin(
	'time_format' => [qw(%R %r %T)],
);

=item date_format

Return a random date format.

=cut

__PACKAGE__->register_plugin(
	'date_format' => [qw(%D %F)],
);

=item ampm_format

Return a random am/pm format.

=cut

__PACKAGE__->register_plugin(
	'ampm_format' => [qw(%p %P)],
);

=item datetime_format

Return a random date and time format.

=cut

__PACKAGE__->register_plugin(
	'datetime_format' => ['%c','%+','%FT%H','%FT%I','%F %H','%F %I'],
);

=item month

Return a random month name, unabbreviated, in the current locale.

=cut

__PACKAGE__->register_plugin(
	'month' => sub { timestr('%B') },
);

=item month_abbr

Return a random month name, abbreviated, in the current locale.

=cut

__PACKAGE__->register_plugin(
	'month_abbr' => sub { timestr('%b') },
);

=item weekday

Return a random weekday name, unabbreviated, in the current locale.

=cut

__PACKAGE__->register_plugin(
	'weekday' => sub { timestr('%A') },
);

=item weekday_abbr

Return a random weekday name, abbreviated, in the current locale.

=cut

__PACKAGE__->register_plugin(
	'weekday_abbr' => sub { timestr('%a') },
);

=item sqldate

Return a random date in the ISO8601 format commonly used by SQL servers
(YYYY-MM-DD).

=cut

__PACKAGE__->register_plugin(
	'sqldate' => sub { timestr('%F') },
);

=item datetime_locale

Return a datetime string in the preferred date representation for the
current locale, for a random date.

=cut

__PACKAGE__->register_plugin(
	'datetime_locale' => sub { timestr('%c') },
);

=item date_locale

Return a date string in the preferred date representation for the
current locale, for a random date.

=cut

__PACKAGE__->register_plugin(
	'date_locale' => sub { timestr('%x') },
);

=item time_locale

Return a time string in the preferred date representation for the
current locale, for a random date.

=cut

__PACKAGE__->register_plugin(
	'time_locale' => sub { timestr('%X') },
);

=item century

Return a random century number.

=cut

__PACKAGE__->register_plugin(
	'century' => sub { timestr('%C') },
);

=item dayofmonth

Return a random day of the month.

=cut

__PACKAGE__->register_plugin(
	'dayofmonth' => sub { timestr('%d') },
);

=back

=head1 UTILITY METHODS

=over 4

=item Data::Faker::DateTime::timestr($format);

Given a strftime format specifier, this method passes it through to
L<POSIX::strftime> along with a random date to display in that format.

Perl passes this through to the strftime function of your system library, so
it is possible that some of the formatting tokens used here will not work on
your system.

=cut

{
    # timestr here redefines the one from Benchmark, which is only loaded for tests.
    no warnings 'redefine';

    sub timestr {
        my $format = shift;
        if(ref($format)) { $format = shift }
        POSIX::strftime($format, localtime(__PACKAGE__->unixtime));
    }
}

=back

=head1 NOTES AND CAVEATS

=over 4

=item Be careful building timestamps from pieces

Be very careful about building date/time representations in formats that
are not already listed here.  For example if you wanted to get a date that
consists of just the month and day, you should NOT do this:

  my $faker = Data::Faker->new();
  print join(' ',$faker->month,$faker->dayofmonth)."\n";

This is bad because you might end up with 'February 31' for example.  Instead
you should use the timestr utility function to provide you a formatted time
for a valid date, or better still, write a plugin function that does it:

  my $faker = Data::Faker->new();
  print $faker->my_short_date()."\n";

  package Data::Faker::MyExtras;
  use base qw(Data::Faker);
  use Data::Faker::DateTime;
  __PACKAGE__->register_plugin(
    my_short_date => sub { Data::Faker::DateTime::timestr('%M %e') },
  );

=item POSIX::strftime

See the documentation above regarding the timestr utility method for some
caveats related to strftime and your system library.

=back

=head1 SEE ALSO

L<Data::Faker>

=head1 AUTHOR

Jason Kohles, E<lt>email@jasonkohles.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright 2004-2005 by Jason Kohles

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

1;