DR::DateTime - Easy DateTime implementator.
use DR::DateTime; my $t = new DR::DateTime time; my $t = new DR::DateTime time, '+0300'; my $t = parse DR::DateTime '2017-08-18 12:33:19.1234+0300'; $t->year; $t->month; $t->day; $t->day_of_week; $t->hour; $t->minute; $t->second; $t->nanosecond; $t->add(second => 15, hour => 24, month => 17); $t->subtract(year => 7);
The module provide the same (reduced) API as DateTime.
DateTime is a very usable and good module, but Dump of its objects gets two or three screens, so If You use more than one object DateTime You have too many troubles to debug Your code.
Create DR::DateTime instance. If $timezone is not defined, the module will use $DR::DateTime::Defaults::TZ value.
$timezone
$DR::DateTime::Defaults::TZ
$timezone is used only for "strftime" method.
Default value for $default_timezone is '+0000' (UTC).
$default_timezone
'+0000'
UTC
Parse string and creates and object (or return undef).
undef
The module can parse only standard time format like (may be partly incompleted) %F %T.%N %z (see man strftime).
%F %T.%N %z
Method that works like "strftime" in POSIX. The method has one additional placeholder - %N - nanosecond.
%N
Methods that return part of contained date. Allow:
$t->strftime('%u')
This method allows You to reset some of the local time components in the object to their "zero" values. The "to" parameter is used to specify which values to truncate, and it may be one of year, month, day, hour, minute, or second.
year
month
day
hour
minute
second
These methods allow You add or substract values to object.
$t -> add( year => 1, month => 2, day => 4, hour => 17, minute => 18, second => 19, nanosecond => 50001 ) -> subtract( year => 3, month => 4, day => 5, hour => 22, minute => 23, second => 24, nanosecond => 7829 );
Return timezone that is used for strftime method.
Now DR::DateTime uses only one time zone format: qr/^[+-]\d{2,4}$/. Named time zones are not supported yet.
qr/^[+-]\d{2,4}$/
Retrun timestamp value.
Return timestamp that includes nanoseconds as float value.
Set timezone for the following "strftime" calls.
Clone the value.
Dmitry E. Oboukhov, <unera@debian.org>
Copyright (C) 2017 by Dmitry E. Oboukhov
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.
To install DR::DateTime, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DR::DateTime
CPAN shell
perl -MCPAN -e shell install DR::DateTime
For more information on module installation, please visit the detailed CPAN module installation guide.