ActiveState::DateTime - Date and Time utilities


ActiveState::DateTime - Date and Time utilities


 use ActiveState::DateTime qw(is_leap_year days_in_month check_date month_name_short month_name_long gmt_offset);
 if (is_leap_year($year)) {
    ... do stuff ...
 my $max_days = days_in_month($year, $month);
 if (check_date($year, $month, $day)) {
    ... do stuff ...
 my $short_month_name = month_name_short($month);
 my $long_month_name = month_name_long($month);
 my $offset = gmt_offset();


The ActiveState::DateTime module provide functions that can be used for convenient data and time checks.


This function takes a numerical argument of a year. It returns true if the year is a leap year, otherwise it returns false.

$days = days_in_month($year, $month)

This function returns the number of days in a month and takes into account leap years. The year is a numerical argument. The month is a numerical argument from 1 to 12.

check_date($year, $month, $day)

This function takes numerical arguments for year, month and day and checks to make sure the date is valid. For example:

Is February 29, 2005 a valid date?

Is February 29, 2008 a valid date?

The month is a numerical argument that ranges from 1 to 12.

$month_name = month_name_short($month);

This function returns the English three letter abbreviation of the month name.

$month_name = month_name_long($month);

This function returns the full English month name.

$gmt_offset = gmt_offset();

This function returns the GMT offset.

No functions are exported by default.


Copyright (C) 2003 ActiveState Corp. All rights reserved.