Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

data::faker::datetime(3pm) [debian man page]

Data::Faker::DateTime(3pm)				User Contributed Perl Documentation				Data::Faker::DateTime(3pm)

NAME
Data::Faker::DateTime - Data::Faker plugin SYNOPSIS AND USAGE
See Data::Faker DATA PROVIDERS
unixtime Return a unix time (seconds since the epoch) for a random time between the epoch and now. date Return a random date as a string, using a random date format (see date_format). time Return a random time as a string, using a random time format (see time_format). 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.) ampm Returns am or pm randomly (in the current locale) using one of the formats specified in ampm_format. time_format Return a random time format. date_format Return a random date format. ampm_format Return a random am/pm format. datetime_format Return a random date and time format. month Return a random month name, unabbreviated, in the current locale. month_abbr Return a random month name, abbreviated, in the current locale. weekday Return a random weekday name, unabbreviated, in the current locale. weekday_abbr Return a random weekday name, abbreviated, in the current locale. sqldate Return a random date in the ISO8601 format commonly used by SQL servers (YYYY-MM-DD). datetime_locale Return a datetime string in the preferred date representation for the current locale, for a random date. date_locale Return a date string in the preferred date representation for the current locale, for a random date. time_locale Return a time string in the preferred date representation for the current locale, for a random date. century Return a random century number. dayofmonth Return a random day of the month. UTILITY METHODS
Data::Faker::DateTime::timestr($format); Given a strftime format specifier, this method passes it through to 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. NOTES AND CAVEATS
Be careful build 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)." "; 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()." "; 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') }, ); POSIX::strftime See the documentation above regarding the timestr utility method for some caveats related to strftime and your system library. SEE ALSO
Data::Faker AUTHOR
Jason Kohles, <email@jasonkohles.com> 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. perl v5.10.1 2005-07-14 Data::Faker::DateTime(3pm)

Check Out this Related Man Page

Template::Plugin::Date(3)				User Contributed Perl Documentation				 Template::Plugin::Date(3)

NAME
Template::Plugin::Date - Plugin to generate formatted date strings SYNOPSIS
[% USE date %] # use current time and default format [% date.format %] # specify time as seconds since epoch # or as a 'h:m:s d-m-y' or 'y-m-d h:m:s' string [% date.format(960973980) %] [% date.format('4:20:36 21/12/2000') %] [% date.format('2000/12/21 4:20:36') %] # specify format [% date.format(mytime, '%H:%M:%S') %] # specify locale [% date.format(date.now, '%a %d %b %y', 'en_GB') %] # named parameters [% date.format(mytime, format = '%H:%M:%S') %] [% date.format(locale = 'en_GB') %] [% date.format(time = date.now, format = '%H:%M:%S', locale = 'en_GB) %] # specify default format to plugin [% USE date(format = '%H:%M:%S', locale = 'de_DE') %] [% date.format %] ... DESCRIPTION
The "Date" plugin provides an easy way to generate formatted time and date strings by delegating to the "POSIX" "strftime()" routine. The plugin can be loaded via the familiar USE directive. [% USE date %] This creates a plugin object with the default name of '"date"'. An alternate name can be specified as such: [% USE myname = date %] The plugin provides the "format()" method which accepts a time value, a format string and a locale name. All of these parameters are optional with the current system time, default format ('"%H:%M:%S %d-%b-%Y"') and current locale being used respectively, if undefined. Default values for the time, format and/or locale may be specified as named parameters in the "USE" directive. [% USE date(format = '%a %d-%b-%Y', locale = 'fr_FR') %] When called without any parameters, the "format()" method returns a string representing the current system time, formatted by "strftime()" according to the default format and for the default locale (which may not be the current one, if locale is set in the "USE" directive). [% date.format %] The plugin allows a time/date to be specified as seconds since the epoch, as is returned by "time()". File last modified: [% date.format(filemod_time) %] The time/date can also be specified as a string of the form "h:m:s d/m/y" or "y/m/d h:m:s". Any of the characters : / - or space may be used to delimit fields. [% USE day = date(format => '%A', locale => 'en_GB') %] [% day.format('4:20:00 9-13-2000') %] Output: Tuesday A format string can also be passed to the "format()" method, and a locale specification may follow that. [% date.format(filemod, '%d-%b-%Y') %] [% date.format(filemod, '%d-%b-%Y', 'en_GB') %] A fourth parameter allows you to force output in GMT, in the case of seconds-since-the-epoch input: [% date.format(filemod, '%d-%b-%Y', 'en_GB', 1) %] Note that in this case, if the local time is not GMT, then also specifying '%Z' (time zone) in the format parameter will lead to an extremely misleading result. Any or all of these parameters may be named. Positional parameters should always be in the order "($time, $format, $locale)". [% date.format(format => '%H:%M:%S') %] [% date.format(time => filemod, format => '%H:%M:%S') %] [% date.format(mytime, format => '%H:%M:%S') %] [% date.format(mytime, format => '%H:%M:%S', locale => 'fr_FR') %] [% date.format(mytime, format => '%H:%M:%S', gmt => 1) %] ...etc... The "now()" method returns the current system time in seconds since the epoch. [% date.format(date.now, '%A') %] The "calc()" method can be used to create an interface to the "Date::Calc" module (if installed on your system). [% calc = date.calc %] [% calc.Monday_of_Week(22, 2001).join('/') %] The "manip()" method can be used to create an interface to the "Date::Manip" module (if installed on your system). [% manip = date.manip %] [% manip.UnixDate("Noon Yesterday","%Y %b %d %H:%M") %] AUTHORS
Thierry-Michel Barral wrote the original plugin. Andy Wardley provided some minor fixups/enhancements, a test script and documentation. Mark D. Mills cloned "Date::Manip" from the "Date::Calc" sub-plugin. COPYRIGHT
Copyright (C) 2000-2007 Thierry-Michel Barral, Andy Wardley. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Plugin, POSIX perl v5.12.1 2009-06-30 Template::Plugin::Date(3)
Man Page