NAME

Time::Str::Regexp - Precompiled regular expressions for date/time formats

SYNOPSIS

use Time::Str::Regexp qw( $RFC3339_Rx $RFC2822_Rx $DateTime_Rx );

if ($string =~ $RFC3339_Rx) {
  my %date = %+;
  ...
}

DESCRIPTION

This module provides precompiled regular expressions for parsing date/time strings in various standard formats. Each regex uses named captures to extract date and time components.

All regexes are anchored (\A ... \z). They perform structural matching only; semantic validation (e.g., day-of-month range, leap years) is not performed by the regex.

NAMED CAPTURES

Successful matches populate %+ with the following keys:

year

Four-digit year (two-digit for ASN1UT, RFC5280, and RFC 850 within RFC2616).

month

Month number or name, depending on format.

day

Day of month.

hour

Hour (0-23, or 1-12 with meridiem).

minute

Minute.

second

Second.

fraction

Fractional digits of the least significant time component present (may represent fractional seconds, minutes, or hours).

day_name

Day name when present (e.g., Mon, Monday).

meridiem

AM/PM indicator (DateTime only).

tz_offset

Numeric timezone offset (e.g., +0100, +01:00).

tz_utc

UTC designator (e.g., Z, GMT, UTC).

tz_abbrev

Timezone abbreviation (e.g., EST, CET).

tz_annotation

RFC 9557 annotation tag (e.g., [Europe/Paris]).

EXPORTED VARIABLES

All variables are exportable on request. Nothing is exported by default.

Profiles of ISO 8601

$ISO8601_Rx - ISO 8601 (basic and extended format)
$RFC4287_Rx - Atom feed timestamp (RFC 4287)
$W3CDTF_Rx - W3C Date and Time Format
$RFC5545_Rx - iCalendar (RFC 5545)

Based on ISO 8601

$RFC3339_Rx - Internet timestamp (RFC 3339)
$RFC9557_Rx - Timestamps with annotations (RFC 9557)
$ISO9075_Rx - SQL timestamp (ISO 9075)
$ASN1GT_Rx - ASN.1 GeneralizedTime
$ASN1UT_Rx - ASN.1 UTCTime
$RFC5280_Rx - X.509 certificate time (RFC 5280)

RFC / IMF / HTTP / IMAP

$RFC2822_Rx - Internet Message Format (RFC 2822, canonical)
$RFC2822FWS_Rx - RFC 2822 with folding white space and nested comments
$RFC2616_Rx - HTTP-date (RFC 2616 / RFC 7231)
$RFC3501_Rx - IMAP date-time (RFC 3501)

Unix / C Library

$ANSIC_Rx - ANSI C ctime()/asctime()
$UnixDate_Rx - Unix date(1) output
$UnixStamp_Rx - Unix date based, with optional fractional seconds and timezone
$GitDate_Rx - Git default date format
$RubyDate_Rx - Ruby/Rails date format

Other

$ECMAScript_Rx - ECMAScript Date.prototype.toString
$CLF_Rx - Common Log Format
$DateTime_Rx - Permissive multi-format parser

FUNCTIONS

mapping

my %map = Time::Str::Regexp->mapping;
my $map = Time::Str::Regexp->mapping;  # hashref in scalar context

Returns the format name to regex mapping. Keys are lowercase format names; values are precompiled regexes.

SEE ALSO

Time::Str

AUTHOR

Christian Hansen

COPYRIGHT AND LICENSE

Copyright (C) 2026 by Christian Hansen

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