Date::Utility - A class that represents a datetime in various format
use Date::Utility; Date::Utility->new(); # Use current time Date::Utility->new(1249637400); Date::Utility->new('dd-mmm-yy'); Date::Utility->new('dd-mmm-yyyy'); Date::Utility->new('dd-Mmm-yy hh:mm:ssGMT'); Date::Utility->new('dd-Mmm-yy hhhmm'); Date::Utility->new('YYYY-MM-DD'); Date::Utility->new('YYYYMMDD'); Date::Utility->new('YYYYMMDDHHMMSS'); Date::Utility->new('YYYY-MM-DD HH:MM:SS'); Date::Utility->new('YYYY-MM-DDTHH:MM:SSZ');
A class that represents a datetime in various format
return day of week begin with 0
Returns time in hh:mm format
Returns time in hh:mm:ss format
Set the timezone for cutoff to UTC
Returns year in two digit format. Example: 15
Set the timezone to GMT
See, db_timestamp
Returns datetime in "dd-mmm-yy hh:mm:ssGMT" format
Returns datetime in "dd-mmm-yy hh:mm:ss" format
Returns date in dd-mmm-yyyy format
Returns date in dd-month-yyyy format
Returns datetime in YYYY-MM-DD format
Returns datetime in dd-Mmm-yy format
Returns number of days since 1970-01-01
Returns number of seconds after midnight of the same day.
Returns a Date::Utility object.
User may supplies datetime parameters but it currently only supports the following formats: dd-mmm-yy ddhddGMT, dd-mmm-yy, dd-mmm-yyyy, dd-Mmm-yy hh:mm:ssGMT, YYYY-MM-DD, YYYYMMDD, YYYYMMDDHHMMSS, yyyy-mm-dd hh:mm:ss, yyyy-mm-ddThh:mm:ss or yyyy-mm-ddThh:mm:ssZ.
Returns number of days between two dates.
Returns a boolean which indicates whether this date object is earlier in time than the supplied date object.
Returns a boolean which indicates whether this date object is later in time than the supplied date object.
Returns a boolean which indicates whether this date object is the same time as the supplied date object.
Returns the name of the current day in short form. Example: Sun.
Returns the name of the current day. Example: Sunday
Returns the name of current month in short form. Example: Jan
Returns the full name of current month. Example: January
Returns datetime in this format: Fri, 27 Nov 2009 02:12:02 GMT
Returns date in this format "dd-mm-yy" (28-02-10)
Returns date in this format "dd-mm-yyyy" (28-02-2010)
Returns date in this format "yyyy-mm-dd" (2010-03-02)
Returns: "yyyy-mm-dd hh:mm:ss" (2010-03-02 05:09:40)
Since all internal representations are in UTC Returns "yyyy-mm-ddThh:mm:ssZ" (2010-02-02T05:09:40Z)
Returns datetime in this format "yyyy-mm-dd hh:mm:ssGMT" (2010-03-02 05:09:40GMT)
Returns a TimeInterval which represents the difference between UTC and the time in certain timezone
Returns a boolean which indicates whether a certain zone is in DST at the given epoch
Returns a new Date::Utility plus the supplied Time::Duration::Concise::Localize. Negative TimeIntervals will move backward.
Will also attempt to create a TimeInterval from a supplied code, if possible.
Returns a new Date::Utility minus the supplied Time::Duration::Concise::Localize. Negative TimeIntervals will move forward.
Returns the month ahead or backward from the supplied month in the format of Mmm-yy. It could hanlde backward or forward move from the supplied month.
Takes an integer as an ordinal and a day of week representation
The following are all equivalent: move_to_nth_dow(3, 'Monday') move_to_nth_dow(3, 'Mon') move_to_nth_dow(3, 1)
move_to_nth_dow(3, 'Monday')
move_to_nth_dow(3, 'Mon')
move_to_nth_dow(3, 1)
Returning the 3rd Monday of the month represented by the object or undef if it does not exist.
undef
An exception is thrown on improper day of week representations.
Static method returns a standard mapping from month numbers to our 3 character abbreviated format.
Static method returns a standard mapping from 3 character abbreviated format to month numbers
Static method returns a standard mapping from month numbers to fullname.
Check if a given datetime is an epoch timestemp, i.e. an integer of under 14 digits.
Check if a given "date" is in dd-Mmm-yy format (e.g. 1-Oct-10)
Returns a Date::Utility object with the time part truncated out of it.
For instance, '2011-12-13 23:24:25' will return a new Date::Utility object representing '2011-12-13 00:00:00'
Returns a Date::Utility object with the day and time part truncated out of it.
For instance, '2011-12-13 23:24:25' will return a new Date::Utility object representing '2011-12-01 00:00:00'
Returns a Date::Utility object with the minutes and seconds truncated out of it.
For instance, '2011-12-13 23:24:25' will return a new Date::Utility object representing '2011-12-13 23:00:00'
Returns Date::Utility object for the start of the current day. Much faster than Date::Utility->new, as it will return the same object till the end of the day.
Takes the following argument as named parameter:
years - number of years to be added. (Integer)
years
Returns a new Date::Utility object plus the given years. If the day is greater than days in the new month, it will take the day of end month. e.g.
print Date::Utility->new('2000-02-29')->plus_years(1)->date_yyyymmdd; # will print 2001-02-28
years - number of years to be subracted. (Integer)
Returns a new Date::Utility object minus the given years. If the day is greater than days in the new month, it will take the day of end month. e.g.
print Date::Utility->new('2000-02-29')->minus_years(1)->date_yyyymmdd; # will print 1999-02-28
years - number of months to be added. (Integer)
Returns a new Date::Utility object plus the given months. If the day is greater than days in the new month, it will take the day of end month. e.g.
print Date::Utility->new('2000-01-31')->plus_months(1)->date_yyyymmdd; # will print 2000-02-28
years - number of months to be subracted. (Integer)
Returns a new Date::Utility object minus the given months. If the day is greater than days in the new month, it will take the day of end month. e.g.
print Date::Utility->new('2000-03-31')->minus_months(1)->date_yyyymmdd; # will print 2000-02-28
year - calendar year of the date (Integer)
year
month - calendar month of the date. (Integer)
month
day - day of the month of the date. (Integer)
day
Returns a valid Date::Utility object whose date part is same with the given year, month and day and time part is not changed. If the day is greater than the max day in that month , then use that max day as the day in the new object.
Binary.com, <support at binary.com>
<support at binary.com>
Please report any bugs or feature requests to bug-date-utility at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Date-Utility. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-date-utility at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Date::Utility
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Date-Utility
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Date-Utility
CPAN Ratings
http://cpanratings.perl.org/d/Date-Utility
Search CPAN
http://search.cpan.org/dist/Date-Utility/
Copyright 2015 Binary.com.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
BUILDALL, BUILDARGS, DEMOLISHALL, DOES, does, dump
To install Date::Utility, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Date::Utility
CPAN shell
perl -MCPAN -e shell install Date::Utility
For more information on module installation, please visit the detailed CPAN module installation guide.