NAME

Date::Fmtstr2time - Functions to format date/time strings into a Perl Time based on a "Picture" format string.

AUTHOR

Jim Turner

(c) 2015, Jim Turner under the same license that Perl 5 itself is. All rights reserved.

SYNOPSIS

use Date::Fmtstr2time;

print str2time('12-25-2015 07:15 AM', 'mm-dd-yyyy hh:mi PM');

DESCRIPTION

Date::Fmtstr2time provides a single function str2time that accepts a date or date / time in a string (data-string) and a format-string consisting of special substrings which represent the various parts of a date and time value. It returns a standard Perl (Unix) "time" value (a large integer equivalent to the number of seconds since 1980).

METHODS

<$integer> = str2time(data-string, format-string);

Returns a standard Perl (Unix) "time" value (a large integer). The format-string tells the software what format to expect the date / time value in the data-string to be in.

For example:

$s = str2time('01-09-2016 01:20 AM (Sat) (January)', 'mm-dd-yyyy hh:mi PM (Day) (Month)');

would set $s to 1452324000, (the Unix time equivalent).

Special Formatting Substrings

There are numerous choices of special format substrings which can be used in an infinite number of combinations to produce the desired results. They are listed below:

    month - The Full name of the month in all lower case, ie. "january".

    Month - The Full name of the month capitalized, ie. "January".

    MONTH - The Full name of the month all capitalized, ie. "JANUARY".

    dayofweek - Day of the week in all lower case, ie. "sunday".

    Dayofweek - Day of the week capitalized, ie. "Sunday".

    DAYOFWEEK - Day of the week all capitalized, ie. "SUNDAY".

    day - Three letter abbreviation of the day of the week in all lower case, ie. "sun".

    Day - Three letter abbreviation of the day of the week capitalized, ie. "Sun".

    DAY - Three letter abbreviation of the day of the week all capitalized, ie. "SUN".

    ddd - Num. of days since beginning of year.

    dd - Day of month (2 digits, left padded with a zero if needed), ie. "01".

    d1 - Day of month (1 or 2 digits, as needed), ie. "1".

    d0, d - Numeric day of the week zero-based (Sunday=0, Monday=1, ... Saturday=6).

    d1 - Numeric day of the week one-based (Sunday=1, Monday=2, ... Saturday=7).

    yyyymmdd - Numeric date in 8 digits, ie. "20150107" for January 7, 2015.

    yyyy, rrrr - Year in 4 digits.

    yy, rr - Year in last 2 digits.

    hh24 - Military time (hours and minutes: 24 hours, no colon).

    hh - Hour in common format, ie. 01-12.

    h1 - Hour in common format, 1 or 2 digits, as needed, ie. 1-12.

    mi - Minute, ie. 00-59.

    mm - Number of month (2 digits, left padded with a zero if needed), ie. "01" for January.

    mon - Three letter abbreviation of the month, in lower case, ie. "jan" for January.

    HH - Hour in 24-hour format, 2 digits, left padded with a zero if needed, ie. 00-23.

    H1 - Hour in 24-hour format, 1 or 2 digits, as needed, ie. 0-23.

    Mon - Three letter abbreviation of the month, capitalized, ie. "Jan" for January.

    MON - Three letter abbreviation of the month all capitalized, ie. "JAN".

    m1 - Number of month (1 or 2 digits, as needed), ie. "1" for January.

    sssss - Seconds since start of day.

    ss - Seconds since start of last minute (2 digits), ie. 00-59.

    am, pm - display "am" if between Midnight and Noon, "pm" otherwise (both specifiers are identical).

    AM, PM - display "AM" if between Midnight and Noon, "PM" otherwise (both specifiers are identical).

    a, p - display "a" if between Midnight and Noon, "p" otherwise (both specifiers are identical).

    A, P - display "A" if between Midnight and Noon, "P" otherwise (both specifiers are identical).

    rm - Roman numeral for the month (i-xii) in lower case.

    RM - Roman numeral for the month (I-XII) in upper case.

    ww - Number of week of the year (00-51).

    q - Number of the quarter of the year - (1-4).

KEYWORDS

Date::Time2fmtstr, String::PictureFormat, formatting, picture_clause, strings