NAME

Git::Code::Review::Utilities::Date - Date calculation and manipulations

VERSION

version 2.6

SYNOPSIS

use Git::Code::Review::Utilities::Date qw( days_age load_special_days reset_date_caches special_age special_days weekends weekdays_age yyyy_mm_dd_to_gmepoch );

DESCRIPTION

Age, weekend, and special day calculation module optimised for to age calculations from a day in the past to today

NAME

Git::Code::Review::Utilities::Date - Age handling for Git::Code::Review

FUNCTIONS

days_age

my $age = days_age( '2015-07-12' );

Get the number of days between today and the specified day in YYYY-MM-DD format. You can set the date used for today using reset_date_caches() function. If today is '2015-08-12', days_age( '2015-08-11' ) should return 1.

load_special_days

my $special_days = load_special_days( 'national_holidays_nl.txt', 'non_working_days.txt', 'sick_days.txt' );
my $special_days = load_special_days();

Loads special days from one or more text files containing special days in a YYYY-MM-DD format. The files can have one or more dates per line. If more than one dates are on a line, they should be separated by commas. White spaces can be added around the dates and will be ignored and so will any part of the line starting from a # character to allow comments. See the holidays.txt in the tests for a sample file. Special days falling on a Saturday or a Sunday are ignored.

Returns a copy of the currently loaded special days. Call without any arguments to get the complete current list of special days. You can also use special_days() to get a list of special days between two dates.

reset_date_caches

reset_date_caches();
reset_date_caches( yyyy_mm_dd_to_gmepoch( '2015-08-01' ) );

Clear all the internal caches of ages and special days and reset the TODAY epoch used internally to the current day or the one supplied. Useful when the day changes or during testing. Do remember to load the special days if you want them again.

special_age

my $age = special_age( '2015-08-01' );

Get the number of days between today and the specified day in YYYY-MM-DD format excluding the weekend days and currently loaded special days. You can set the date used for today using reset_date_caches() function.

special_days

my $special_days = special_days( yyyy_mm_dd_to_gmepoch( '2015-04-01' ), yyyy_mm_dd_to_gmepoch( '2015-04-30' ) );

Get a array_ref to the special days included in the given date range, both inclusive. The returned list contains epochs as returned by yyyy_mm_dd_to_gmepoch() function.

weekends

my $weekends = weekends( $start_day, $days );
my $weekends = weekends( 1, 10 ); # 1 = Monday && 10 days

Returns the number of weekend days in a period of days starting on a given week day. The start_day can be 0 .. 6 for Sunday .. Saturday or 1 .. 7 for Monday .. Sunday.

weekdays_age

my $age = weekdays_age( '2015-08-01' );

Get the number of days between today and the specified date in YYYY-MM-DD format excluding the weekend days. You can set the date used for today using reset_date_caches() function.

yyyy_mm_dd_to_gmepoch

my $epoch = yyyy_mm_dd_to_gmepoch( '2015-08-01' );

Returns the midnight epoch for the date specified in the YYYY-MM-DD format in GMT timezone. There is no Daylight Saving Time in GMT, which makes it easier for calculations.

AUTHOR

Samit Badle

COPYRIGHT

(c) 2015 All rights reserved.

AUTHOR

Brad Lhotsky <brad@divisionbyzero.net>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2014 by Brad Lhotsky.

This is free software, licensed under:

The (three-clause) BSD License