info > Date::Manip::DM5

Not found locally for Date::Manip::DM5. Try Google search

📛 NAME

Date::Manip::DM5 – Date manipulation routines

🚀 Quick Reference

Use CaseCommandDescription
Initialize / configureDate_Init("VAR=VAL",...);Set language, date format, time zone, holidays, etc.
Parse a human date$date = ParseDate($string);Convert text like "tomorrow at noon" into internal form.
Format a date for display@date = UnixDate($date,@format);Emulate date(1) formats (%Y, %m, %d, …).
Parse a time interval$delta = ParseDateDelta($string);Convert "+2 days 3 hours" into a delta structure.
Format a delta$str = Delta_Format($delta,$dec,@format);Express delta in hours, minutes, etc.
Define a recurring event$recur = ParseRecur($string,...);Create recurrence rules like "every 2nd Tuesday".
Compare two dates$flag = Date_Cmp($date1,$date2);Compare dates, respecting time zones.
Date arithmetic$d = DateCalc($d1,$d2 [,$errref]);Add/subtract dates and deltas, business mode possible.
Set a time component$date = Date_SetTime($date,$hr,$min,$sec);Change the time portion of a date.
Find previous/following$date = Date_GetPrev($date,$dow,...);Locate prior occurrence of a day or time.
Check holiday$name = Date_IsHoliday($date);Returns holiday name if date is a holiday.
Convert between time zones$date = Date_ConvTZ($date,$from,$to);Shift date between time zone definitions.
Work day handling$flag = Date_IsWorkDay($date);Test if date is a business/work day.

📝 SYNOPSIS

All public routines check that Date_Init has been called, and call it automatically if not. The internal routines (listed later) are faster but require explicit Date_Init and little error checking.

use Date::Manip;

$version = DateManipVersion;

Date_Init();
Date_Init("VAR=VAL","VAR=VAL",...);
@list = Date_Init();
@list = Date_Init("VAR=VAL","VAR=VAL",...);

$date = ParseDate(\@args);
$date = ParseDate($string);
$date = ParseDate(\$string);

@date = UnixDate($date,@format);
$date = UnixDate($date,@format);

$delta = ParseDateDelta(\@args);
$delta = ParseDateDelta($string);
$delta = ParseDateDelta(\$string);

@str = Delta_Format($delta,$dec,@format);
$str = Delta_Format($delta,$dec,@format);

$recur = ParseRecur($string,$base,$date0,$date1,$flags);
@dates = ParseRecur($string,$base,$date0,$date1,$flags);

$flag = Date_Cmp($date1,$date2);

$d = DateCalc($d1,$d2 [,$errref] [,$del]);

$date = Date_SetTime($date,$hr,$min,$sec);
$date = Date_SetTime($date,$time);

$date = Date_SetDateField($date,$field,$val [,$nocheck]);

$date = Date_GetPrev($date,$dow,$today,$hr,$min,$sec);
$date = Date_GetPrev($date,$dow,$today,$time);

$date = Date_GetNext($date,$dow,$today,$hr,$min,$sec);
$date = Date_GetNext($date,$dow,$today,$time);

$name = Date_IsHoliday($date);

$listref = Events_List($date);
$listref = Events_List($date0,$date1);

$date = Date_ConvTZ($date);
$date = Date_ConvTZ($date,$from);
$date = Date_ConvTZ($date,"",$to);
$date = Date_ConvTZ($date,$from,$to);

$flag = Date_IsWorkDay($date [,$flag]);

$date = Date_NextWorkDay($date,$off [,$flag]);

$date = Date_PrevWorkDay($date,$off [,$flag]);

$date = Date_NearestWorkDay($date [,$tomorrowfirst]);

# Internal (fast) routines – require explicit Date_Init:

$day = Date_DayOfWeek($m,$d,$y);
$secs = Date_SecsSince1970($m,$d,$y,$h,$mn,$s);
$secs = Date_SecsSince1970GMT($m,$d,$y,$h,$mn,$s);
$days = Date_DaysSince1BC($m,$d,$y);
$day = Date_DayOfYear($m,$d,$y);
($y,$m,$d,$h,$mn,$s) = Date_NthDayOfYear($y,$n);
$days = Date_DaysInYear($y);
$days = Date_DaysInMonth($m,$y);
$wkno = Date_WeekOfYear($m,$d,$y,$first);
$flag = Date_LeapYear($y);
$day = Date_DaySuffix($d);
$tz = Date_TimeZone();

📚 ROUTINES

🔹 Date_Init

Date_Init();
Date_Init("VAR=VAL","VAR=VAL",...);
@list = Date_Init();
@list = Date_Init("VAR=VAL","VAR=VAL",...);

Normally, Date_Init is called automatically by other routines. Call explicitly only to change configuration. Strings are of the form "VAR=VAL". In list context, returns current config values (suitable for later restoration).

Example – switch to French with non‑US date order:

Date_Init("Language=French","DateFormat=non-US");

To restore state later, prepend "EraseHolidays=1" if needed.

📅 ParseDate

$date = ParseDate(\@args);
$date = ParseDate($string);
$date = ParseDate(\$string);

Extracts a date from an array reference (shifts used elements) or from a string. Useful for processing command‑line arguments. The core parsing is done by ParseDateString.

🔍 ParseDateString

$date = ParseDateString($string);

Parses a single string into an internal date. Handles many formats (ISO 8601, US/European, relative, etc.).

⏱️ Time Specification

A time is [at] HH:MN [am|pm] [Zone], optionally with seconds :SS and fractional seconds (ignored). 12‑hour mode requires AM/PM. Zone follows the time.

📆 ISO 8601 Formats

YYYYMMDDHHMNSSF...
YYYYMMDDHHMNSS
YYYYMMDDHHMN
YYYYMMDDHH
YY-MMDDHHMNSSF...
YY-MMDDHHMNSS
YY-MMDDHHMN
YY-MMDDHH
YYYYMMDD
YYYYMM
YYYY
YY-MMDD
YY-MM
YY
YYYYwWWD      ex.  1965-W02-2
YYwWWD
YYYYDOY       ex.  1965-045
YYDOY

Dashes are optional except where shown. T may separate date and time. Time zone can be any Date::Manip‑understood zone.

🇺🇸🇪🇺 Other Common Formats

Formats using month names (mmm) and numeric parts separated by space, / or . (dash may conflict with ISO). Month/day order depends on DateFormat variable.

MM/DD  **
MM/DD/YY  **
MM/DD/YYYY  **

mmmDD       DDmmm                   mmmYYYY/DD     mmmYYYY
mmmDD/YY    DDmmmYY     DD/YYmmm    YYYYmmmDD      YYYYmmm
mmmDDYYYY   DDmmmYYYY   DDYYYYmmm   YYYY/DDmmm

🗣️ Relative / Natural‑Language Formats

Words like “in”, “at”, “of” are ignored. Year is optional; defaults to current year.

📌 Recognized Strings

📋 Important Notes

🖨️ UnixDate

@date = UnixDate($date,@format);
$date = UnixDate($date,@format);

Takes a date and one or more format strings, returns formatted strings.

📐 Format Specifiers

The %l format mimics ls -l: %b %e %H:%M within 6 months, else %b %e %Y.

For week numbers, use (%W,%G) or (%U,%L) to avoid year‑boundary errors.

Negative %s and %o values are possible for pre‑epoch dates.

🔧 ParseDateDelta

$delta = ParseDateDelta(\@args);
$delta = ParseDateDelta($string);
$delta = ParseDateDelta(\$string);

Parses a time delta (duration). Recognised forms:

+Yy +Mm +Ww +Dd +Hh +MNmn +Ss        (any order, separated by space)
+Y:+M:+W:+D:+H:+MN:+S                   (colon separated, 2‑7 fields)
mixed: 4 hour 3:-2

Units: y (year), m (month), w (week), d (day), h (hour), mn (minute), s (second). “in” is ignored; “ago” reverses sign. Normalised output forces all‑positive or all‑negative, separately for year/month and day/hour/minute/second segments.

🔣 Delta_Format

@str = Delta_Format($delta [,$mode], $dec,@format);
$str = Delta_Format($delta [,$mode], $dec,@format);

Formats a delta value. Two‑character format codes: %Xv (value of field X), %Xd (field X and smaller expressed in units of X), %Xh (field X and larger in units of X), %Xt (total delta in units of X). X is y,M,w,d,h,m,s (case‑sensitive).

Exact mode (default) keeps year/month and day/time segments separate. Approximate mode (pass "approx" as second argument) uses 1 year = 365.25 days, 1 month = 1/12 year.

🔁 ParseRecur

$recur = ParseRecur($string [,$base,$date0,$date1,$flags]);
@dates = ParseRecur($string [,$base,$date0,$date1,$flags]);

Defines recurring events. The full specification is freq*flags*base*date0*date1. Frequency description: Y:M:W:D:H:MN:S, with exactly one asterisk to separate interval and specific values. Values after asterisk can be single, range (2‑5), or comma‑separated list; negative numbers count from the end.

Examples:

1:2*3:4:5:6:7           every 1 year 2 months, on the 3rd day of 4th week at 05:06:07
0:0:0:2*12:30:0         every 2 days at 12:30
0:0:0:1*2,4,6:0:0       every day at 02:00, 04:00, 06:00
1*12:0:24:0:0:0*FW1     Christmas (observance)

Day field after asterisk can mean day‑of‑week, day‑of‑month, or day‑of‑year depending on the surrounding fields. Week and month contexts alter interpretation.

Flags (case‑insensitive): PDn, PTn, NDn, NTn (previous/next day of week), FDn, BDn, FWn, BWn, CWD, CWN, CWP, NWD, PWD, DWD, EASTER. Another way to define “every Tuesday” etc. is via English phrases, which set default base/date0/date1.

⚖️ Date_Cmp

$flag = Date_Cmp($date1,$date2);

Compares two dates, considering time zones. (Currently a wrapper around cmp, but future‑proof.)

🔢 DateCalc

$d = DateCalc($d1,$d2 [,\$err] [,$mode]);

Adds dates and/or deltas. If two dates → delta; if two deltas → delta; if date+delta → date. Modes: 0 (exact, default), 1 (approximate, shows years/months), 2 (business, uses holidays/work hours), 3 (exact business delta). Keywords “approximately”, “business”, “exactly” in the arguments can override mode. Error reference \$err receives 1/2/3 on failure. Returns nothing on error.

⏰ Date_SetTime

$date = Date_SetTime($date,$hr,$min,$sec);
$date = Date_SetTime($date,$time);

Sets the time portion of a date. Accepts "HH:MM:SS" or separate arguments.

🔨 Date_SetDateField

$date = Date_SetDateField($date,$field,$val [,$nocheck]);

Sets a single field (y, m, d, h, mn, s). With $nocheck true, validity is not enforced.

⏪ Date_GetPrev

$date = Date_GetPrev($date,$dow, $curr [,$hr,$min,$sec]);
$date = Date_GetPrev($date,$dow, $curr [,$time]);
$date = Date_GetPrev($date,undef,$curr,$hr,$min,$sec);
$date = Date_GetPrev($date,undef,$curr,$time);

Finds the previous occurrence of a given day‑of‑week or time. $dow can be name (Fri) or number (1‑7). $curr determines handling when date matches: 0 → previous week, 1 → same day, 2 → strictly before. If $dow is undef, finds previous matching time (like a digital clock).

⏩ Date_GetNext

Same as Date_GetPrev but forward.

🎊 Date_IsHoliday

$name = Date_IsHoliday($date);

Returns holiday name or undef. Empty string for unnamed holidays.

📋 Events_List

$ref = Events_List($date);
$ref = Events_List($date ,0      [,$flag]);
$ref = Events_List($date0,$date1 [,$flag]);

Returns a list of events defined in the config file’s Events section. In the first form, returns events active at that instant. With range, returns changes. $flag controls format: 0 → list of (date, [events]), 1 → tally per event, 2 → tally with unique combinations.

🌐 Date_ConvTZ

$date = Date_ConvTZ($date);
$date = Date_ConvTZ($date,$from);
$date = Date_ConvTZ($date,"",$to [,$errlev]);
$date = Date_ConvTZ($date,$from,$to [,$errlev]);

Converts between time zones. Defaults use ConvTZ config variable. $errlev: 0 → die, 1 → warn, 2 → silent return.

🏢 Date_IsWorkDay

$flag = Date_IsWorkDay($date [,$flag]);

Returns 1 if date is a work day. Second argument non‑zero checks work hours as well.

➡️ Date_NextWorkDay

$date = Date_NextWorkDay($date,$off [,$flag]);

Steps forward $off work days. Non‑zero flag respects time of day.

⬅️ Date_PrevWorkDay

Similar, backward.

🎯 Date_NearestWorkDay

$date = Date_NearestWorkDay($date [,$tomorrowfirst]);

Finds nearest work day. If date is work day, returns it. Otherwise looks forward first if $tomorrowfirst is true (or config TomorrowFirst).

📦 Internal Routines (Fast)

These skip most error checks and require explicit Date_Init. They receive numeric arguments.

$day = Date_DayOfWeek($m,$d,$y);           # 1=Mon, 7=Sun
$secs = Date_SecsSince1970($m,$d,$y,$h,$mn,$s);   # seconds since epoch local
$secs = Date_SecsSince1970GMT($m,$d,$y,$h,$mn,$s); # seconds since epoch GMT
$days = Date_DaysSince1BC($m,$d,$y);               # days since Dec 31, 1BC
$day = Date_DayOfYear($m,$d,$y);                   # 001-366
($y,$m,$d,$h,$mn,$s) = Date_NthDayOfYear($y,$n);   # day of year -> date
$days = Date_DaysInYear($y);                        # 365 or 366
$days = Date_DaysInMonth($m,$y);                    # days in month
$wkno = Date_WeekOfYear($m,$d,$y,$first);          # week number (0‑53)
$flag = Date_LeapYear($y);                          # 1 if leap year
$day = Date_DaySuffix($d);                          # 'st','nd','rd','th'
$tz = Date_TimeZone();                              # local time zone abbreviation

For Date_WeekOfYear, prefer UnixDate with %W, %U, etc., because the raw result may need adjustment for ISO‑8601.

🕒 TIME ZONES

Date::Manip 5.xx supports the following time zone specifications. Daylight saving time is **not** handled reliably; that will be fixed in version 6.xx.

🌍 RFC‑822 Zones

🕰️ Legacy Abbreviations (backward compatibility)

All other time zone abbreviations are taken from the Olson/zoneinfo database (see Date::Manip::DM5abbrevs). Some abbreviations are ambiguous; only the most common mapping is available.

Date::Manip tries to determine the local time zone from $Date::Manip::TZ, $ENV{TZ}, the Unix date command, $main::TZ, /etc/TIMEZONE, or /etc/timezone. Use Date_Init to set TZ if automatic detection fails.

The STD#DST format is allowed for the TZ variable but not when parsing a date. Also recognised: US/Pacific, US/Mountain, US/Central, US/Eastern, Canada/Pacific, …

⚙️ CUSTOMIZING DATE::MANIP

Configuration can be set in Manip.pm, a global config file, a personal config file, or via Date_Init. The personal config file is named .DateManip.cnf (Unix) or Manip.cnf (Windows). Search path defined by PersonalCnfPath.

A config file consists of assignment lines (VARIABLE = VALUE) and sections starting with *Section. Comments begin with #.

📋 DATE::MANIP VARIABLES

🎉 HOLIDAY SECTION

Holiday definitions in the config file:

*Holiday
DATE = HOLIDAY_NAME

DATE can be:

Use recurrences to handle observed holidays. Business mode keywords are allowed in the Date or Delta. To avoid overwriting identical recurrences, make them unique by adding an ignored flag or a leading zero.

Example:

1*12:0:24:0:0:0*FW1  = Christmas
1*12:0:25:0:0:0*FW1  = Boxing
# or
1*12:0:24:0:0:0*FW1  = Christmas
01*12:0:24:0:0:0*FW1 = Boxing

📅 EVENTS SECTION

Events are defined similarly but do not affect business calculations:

*Events
EVENT = NAME

EVENT can be:

⚠️ KNOWN PROBLEMS

🐛 KNOWN BUGS

🐞 BUGS AND QUESTIONS

Refer to Date::Manip::Problems for reporting guidance.

🔗 SEE ALSO

Date::Manip – main module documentation

©️ LICENSE

This software is free; you can redistribute and/or modify it under the same terms as Perl itself.

✍️ AUTHOR

Sullivan Beck (sbeck AT cpan.org)

perl v5.32.1 2021‑11‑20 Date::Manip::DM5(3pm)

Date::Manip::DM5
📛 NAME 🚀 Quick Reference 📝 SYNOPSIS 📚 ROUTINES
🔹 Date_Init 📅 ParseDate 🔍 ParseDateString 🖨️ UnixDate 🔧 ParseDateDelta 🔣 Delta_Format 🔁 ParseRecur ⚖️ Date_Cmp 🔢 DateCalc ⏰ Date_SetTime 🔨 Date_SetDateField ⏪ Date_GetPrev ⏩ Date_GetNext 🎊 Date_IsHoliday 📋 Events_List 🌐 Date_ConvTZ 🏢 Date_IsWorkDay ➡️ Date_NextWorkDay ⬅️ Date_PrevWorkDay 🎯 Date_NearestWorkDay 📦 Internal Routines (Fast)
🕒 TIME ZONES ⚙️ CUSTOMIZING DATE::MANIP
📋 DATE::MANIP VARIABLES
🎉 HOLIDAY SECTION 📅 EVENTS SECTION ⚠️ KNOWN PROBLEMS 🐛 KNOWN BUGS 🐞 BUGS AND QUESTIONS 🔗 SEE ALSO ©️ LICENSE ✍️ AUTHOR

Generated by phpman v4.10.0-7-g98e9fd5 Author: Che Dong Under GNU General Public License
2026-09-07 07:59 @2600:1f28:365:80b0:d222:ca63:50d7:f9b2
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!