Mojar::Cron::Util - Time utility functions
use Mojar::Cron::Util 'date_next';
Utility functions for dates and times.
($S, $M, $H, $d, $m, $y) = time_to_zero($S, $M, $H, $d, $m, $y);
Converts time representations to zero-based datetimes. So day 1 translates to 0, while months and years are left 0-based.
($S, $M, $H, $d, $m, $y) = zero_to_time($S, $M, $H, $d, $m, $y);
Converts zero-based datetimes to time representations. So day 0 translates to 1, but months and years are left 0-based.
($S, $M, $H, $d, $m, $y) = cron_to_zero($S, $M, $H, $d, $m, $y);
Converts cron representations to zero-based datetimes. So day 1 translates to 0, month 1 translates to 0 (January), while years are left 0-based.
($S, $M, $H, $d, $m, $y) = zero_to_cron($S, $M, $H, $d, $m, $y);
Converts zero-based datetimes to cron representations. So day 0 translates to 1, month 0 translates to 1 (January), but years are left 0-based.
($S, $M, $H, $d, $m, $y) = life_to_zero($S, $M, $H, $d, $m, $y);
Converts real-life representations to zero-based datetimes. So day 1 translates to 0, month 1 translates to 0 (January), and year 1900 translates to 0.
($S, $M, $H, $d, $m, $y) = zero_to_life($S, $M, $H, $d, $m, $y);
Converts zero-based datetimes to real-life representations. So day 0 translates to 1, month 0 translates to 1 (January), and year 0 translates to 1900.
($S, $M, $H, $d, $m, $y) = balance($S, $M, $H, $d, $m, $y);
Balance-out any simple-minded anomalies such as seconds being less than 0 or greater than 59, or days being less than 0 or greater than 31. This lets you make crude adjustments, such as adding 30 mins, and then letting this function balance it back into the realms of normality. Note that it takes care of everything except the length of months, and so is mainly only used by the two normalise functions which will handle that.
($S, $M, $H, $d, $m, $y) = normalise_utc($S, $M, $H, $d, $m, $y);
Normalises a UTC datetime to a valid value. For example, 31 April translates to 1 May.
($S, $M, $H, $d, $m, $y) = normalise_local($S, $M, $H, $d, $m, $y);
Normalises a local datetime to a valid value. For example, 31 April translates to 1 May.
$today = date_today(); # yyyy-mm-dd
Provides today's date, using the local (system) clock.
$previous = date_previous('2015-03-01'); $yesterday = date_previous(date_today());
Provides the previous date.
$next = date_next('2015-02-28'); $tomorrow = date_next(date_today());
Provides the following date.
$offset = tz_offset; $offset = tz_offset($epoch);
Provides the numeric timezone offset, taking daylight saving into account. It is more portable than
POSIX::strftime('%z')
as it works on non-nix platforms such as Windows. This is required by some date formats, such as in SMTP.
Copyright (C) 2012--2016, Nic Sandfield.
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Mojar::Util, POSIX.
To install Mojar::Cron, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojar::Cron
CPAN shell
perl -MCPAN -e shell install Mojar::Cron
For more information on module installation, please visit the detailed CPAN module installation guide.