Time::DayOfWeek - calculate which Day-of-Week a date is
This documentation refers to version 1.8 of Time::DayOfWeek, which was released on Fri Jul 22 10:16:29:07 -0500 2016.
#!/usr/bin/perl use strict;use warnings;use utf8;use v5.10; use Time::DayOfWeek qw(:dow); my ($year, $month, $day) = (2003, 12, 7); say "The Day-of-Week of $year/$month/$day (YMD) is: ", DayOfWeek($year, $month, $day); say 'The 3-letter abbreviation of the Dow is: ', Dow( $year, $month, $day); say 'The 0-based index of the DoW is: ', DoW( $year, $month, $day);
This module just calculates the Day-of-Week for any particular date. It was inspired by the clean Time::DaysInMonth module written by David Muir Sharnoff <Muir@Idiom.Com>.
Time::DayOfWeek's core function which does the calculation and returns the weekday index answer between 0 and 6. If no Year is supplied, 2000 C.E. is assumed. If no Month or Day is supplied, they are set to 1. Months are 1-based with values between 1 and 12. Days similarly range from 1 through 31.
DoW() is the only function that is exported from a normal 'use Time::DayOfWeek;' command. Other functions can be imported into the local namespace explicitly or with the following tags:
:all - every function described here :dow - only DoW(), Dow(), and DayOfWeek() :nam - only DayNames() and MonthNames() :day - everything but MonthNames()
Dow() is the same as DoW() above but returns 3-letter day abbreviations running from 'Sun' through 'Sat'.
DayOfWeek() is the same as DoW() above but returns full day names from 'Sunday' through 'Saturday'.
DayNames() can override default day names with the strings in @NewDayNames. The current list of day names is returned so call DayNames() with no parameters to obtain a list of the default day names.
An example call for Spanish days would be:
DayNames('Domingo', 'Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado');
MonthNames() has also been included to provide a centralized name set. Just like DayNames(), this function returns the current list of month names so call it with no parameters to obtain a list of the default month names.
Revision history for Perl extension Time::DayOfWeek:
* updated license to GPLv3
* removed PT from VERSION
* had to bump minor version to keep them ascending
* added hack to shift days right one between Feb2008..2009 (still not sure why algorithm skewed)
* added kwalitee && POD tests, bumped minor version
* condensed code && moved POD to bottom
* updated License
* updated DoW param tests to turn zero month or day to one
* updated POD to contain links
* made bin/dow as EXE_FILES && added named month param detection
* removed most eccentric misspellings
* removed indenting from POD NAME field
* added month name data and tidied up for release
* wrote pod and made tests
* original version
From the command shell, please run:
`perl -MCPAN -e "install Time::DayOfWeek"`
or uncompress the package and run the standard:
`perl Makefile.PL; make; make test; make install` or if you don't have `make` but Module::Build is installed, try: `perl Build.PL; perl Build; perl Build test; perl Build install`
Most source code should be Free! Code I have lawful authority over is and shall be! Copyright: (c) 2003-2016, Pip Stuart. Copyleft : This software is licensed under the GNU General Public License (version 3 or later). Please consult HTTP://GNU.Org/licenses/gpl-3.0.txt for important information about your freedom. This is Free Software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. See HTTP://FSF.Org for further information.
Pip Stuart <Pip@CPAN.Org>
To install Time::DayOfWeek, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Time::DayOfWeek
CPAN shell
perl -MCPAN -e shell install Time::DayOfWeek
For more information on module installation, please visit the detailed CPAN module installation guide.