1Data::Faker::DateTime(3U)ser Contributed Perl DocumentatiDoanta::Faker::DateTime(3)
2
3
4

NAME

6       Data::Faker::DateTime - Data::Faker plugin
7

SYNOPSIS AND USAGE

9       See Data::Faker
10

DATA PROVIDERS

12       unixtime
13           Return a unix time (seconds since the epoch) for a random time
14           between the epoch and now.
15
16       date
17           Return a random date as a string, using a random date format (see
18           date_format).
19
20       time
21           Return a random time as a string, using a random time format (see
22           time_format).
23
24       rfc822
25           Return an RFC 822 formatted random date.  This method may not work
26           on systems using a non-GNU strftime implementation (kindly let me
27           know if that is the case.)
28
29       ampm
30           Returns am or pm randomly (in the current locale) using one of the
31           formats specified in ampm_format.
32
33       time_format
34           Return a random time format.
35
36       date_format
37           Return a random date format.
38
39       ampm_format
40           Return a random am/pm format.
41
42       datetime_format
43           Return a random date and time format.
44
45       month
46           Return a random month name, unabbreviated, in the current locale.
47
48       month_abbr
49           Return a random month name, abbreviated, in the current locale.
50
51       weekday
52           Return a random weekday name, unabbreviated, in the current locale.
53
54       weekday_abbr
55           Return a random weekday name, abbreviated, in the current locale.
56
57       sqldate
58           Return a random date in the ISO8601 format commonly used by SQL
59           servers (YYYY-MM-DD).
60
61       datetime_locale
62           Return a datetime string in the preferred date representation for
63           the current locale, for a random date.
64
65       date_locale
66           Return a date string in the preferred date representation for the
67           current locale, for a random date.
68
69       time_locale
70           Return a time string in the preferred date representation for the
71           current locale, for a random date.
72
73       century
74           Return a random century number.
75
76       dayofmonth
77           Return a random day of the month.
78

UTILITY METHODS

80       Data::Faker::DateTime::timestr($format);
81           Given a strftime format specifier, this method passes it through to
82           POSIX::strftime along with a random date to display in that format.
83
84           Perl passes this through to the strftime function of your system
85           library, so it is possible that some of the formatting tokens used
86           here will not work on your system.
87

NOTES AND CAVEATS

89       Be careful building timestamps from pieces
90           Be very careful about building date/time representations in formats
91           that are not already listed here.  For example if you wanted to get
92           a date that consists of just the month and day, you should NOT do
93           this:
94
95             my $faker = Data::Faker->new();
96             print join(' ',$faker->month,$faker->dayofmonth)."\n";
97
98           This is bad because you might end up with 'February 31' for
99           example.  Instead you should use the timestr utility function to
100           provide you a formatted time for a valid date, or better still,
101           write a plugin function that does it:
102
103             my $faker = Data::Faker->new();
104             print $faker->my_short_date()."\n";
105
106             package Data::Faker::MyExtras;
107             use base qw(Data::Faker);
108             use Data::Faker::DateTime;
109             __PACKAGE__->register_plugin(
110               my_short_date => sub { Data::Faker::DateTime::timestr('%M %e') },
111             );
112
113       POSIX::strftime
114           See the documentation above regarding the timestr utility method
115           for some caveats related to strftime and your system library.
116

SEE ALSO

118       Data::Faker
119

AUTHOR

121       Jason Kohles, <email@jasonkohles.com>
122
124       Copyright 2004-2005 by Jason Kohles
125
126       This library is free software; you can redistribute it and/or modify it
127       under the same terms as Perl itself.
128
129
130
131perl v5.36.0                      2022-07-22          Data::Faker::DateTime(3)
Impressum