| 1 | package HTTP::Date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | our $VERSION = '6.07'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | our @EXPORT = qw(time2str str2time); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | our @EXPORT_OK = qw(parse_date time2iso time2isoz); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | require Time::Local; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | our ( @DoW, @MoY, %MoY ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | @DoW = qw(Sun Mon Tue Wed Thu Fri Sat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | @MoY = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | @MoY{@MoY} = ( 1 .. 12 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | my %GMT_ZONE = ( GMT => 1, UTC => 1, UT => 1, Z => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | sub time2str (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | my $time = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time2str: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | $time = time unless defined $time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | my ( $sec, $min, $hour, $mday, $mon, $year, $wday ) = gmtime($time); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | "%s, %02d %s %04d %02d:%02d:%02d GMT", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | $DoW[$wday], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | $mday, $MoY[$mon], $year + 1900, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | $hour, $min, $sec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | sub str2time ($;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 141 | ▶ | my $str = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
str2time: called CC=16 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 141 | ▶ | return undef unless defined $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # fast exit for strictly conforming string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 140 | ▶ | if ( $str | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | =~ /^[SMTWF][a-z][a-z], ([0-9][0-9]) ([JFMAJSOND][a-z][a-z]) ([0-9][0-9][0-9][0-9]) ([0-9][0-9]):([0-9][0-9]):([0-9][0-9]) GMT$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | return eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | my $t = Time::Local::timegm( $6, $5, $4, $1, $MoY{$2} - 1, $3 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | $t < 0 ? undef : $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 137 | my @d = parse_date($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 137 | ▶ | return undef unless @d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 126 | $d[1]--; # month | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 126 | my $tz = pop(@d); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 126 | ▶ | unless ( defined $tz ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 63 | ▶ | unless ( defined( $tz = shift ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 20 | return eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 20 | my $frac = $d[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 20 | $frac -= ( $d[-1] = int($frac) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 20 | my $t = Time::Local::timelocal( reverse @d ) + $frac; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 15 | ▶ | $t < 0 ? undef : $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 106 | my $offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 106 | ▶ | if ( $GMT_ZONE{ uc $tz } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # offset already zero | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | elsif ( $tz =~ /^([-+])?([0-9][0-9]?):?([0-9][0-9])?$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 29 | $offset = 3600 * $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 29 | ▶ | $offset += 60 * $3 if $3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 29 | ▶ | $offset *= -1 if $1 && $1 eq '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$1 and $1 eq "-"
MC/DC100%2/2
$1 and $1 eq "-"
$1
$1 eq "-"
Truth table100%3/3
A and B
A= $1B= $1 eq "-"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | eval { require Time::Zone } || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | $offset = Time::Zone::tz_offset($tz); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | return undef unless defined $offset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 105 | return eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 105 | my $frac = $d[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 105 | $frac -= ( $d[-1] = int($frac) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 105 | my $t = Time::Local::timegm( reverse @d ) + $frac; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 105 | ▶ | $t < 0 ? undef : $t - $offset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | sub parse_date ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 149 | ▶ | local ($_) = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_date: called CC=29 SCAR=33.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 149 | ▶ | return unless defined; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # More lax parsing below | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 149 | s/^\s+//; # kill leading space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 149 | s/^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*//i; # Useless weekday | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 149 | my ( $day, $mon, $yr, $hr, $min, $sec, $tz, $ampm ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # Then we are able to check for most of the formats with this regexp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 149 | ▶ | ( $day, $mon, $yr, $hr, $min, $sec, $tz ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%12/12
() = m[^
([0-9][0-9]?) # day
(?:\s+|[-/])
(\w+) # month
(?:\s+|[-/])
([0-9]+) # year
(?:
(?:\s+|:) # separator before clock
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
)? # optional clock
\s*
([-+]?[0-9]{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
\s*
(?:\(\w+\)|\w{3,})? # ASCII representation of timezone.
\s*$
]x or ($mon, $day, $hr, $min, $sec, $tz, $yr) = /^
(\w{1,3}) # month
\s+
([0-9][0-9]?) # day
\s+
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
\s+
(?:([A-Za-z]+)\s+)? # optional timezone
([0-9]+) # year
\s*$ # allow trailing whitespace
/x or ($mon, $day, $yr, $hr, $min, $sec) = /^
(\w{3}) # month
\s+
([0-9][0-9]?) # day
\s+
(?:
([0-9][0-9][0-9][0-9]) | # year
([0-9]{1,2}):([0-9]{2}) # hour:min
(?::([0-9][0-9]))? # optional seconds
)
\s*$
/x or ($yr, $mon, $day, $hr, $min, $sec, $tz) = m[^
([0-9]{4}) # year
[-/]?
([0-9][0-9]?) # numerical month
[-/]?
([0-9][0-9]?) # day
(?:
(?:\s+|[-:Tt]) # separator before clock
([0-9][0-9]?):?([0-9][0-9]) # hour:min
(?::?([0-9][0-9](?:\.[0-9]*)?))? # optional seconds (and fractional)
)? # optional clock
\s*
([-+]?[0-9][0-9]?:?(?:[0-9][0-9])?
|Z|z)? # timezone (Z is "zero meridian", i.e. GMT)
\s*$
]x or ($mon, $day, $yr, $hr, $min, $ampm) = /^
([0-9]{2}) # numerical month
-
([0-9]{2}) # day
-
([0-9]{2,4}) # year
\s+
([0-9][0-9]?):([0-9][0-9])([APap][Mm]) # hour:min AM or PM
\s*$
/x
() = m[^
([0-9][0-9]?) # day
(?:\s+|[-/])
(\w+) # month
(?:\s+|[-/])
([0-9]+) # year
(?:
(?:\s+|:) # separator before clock
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
)? # optional clock
\s*
([-+]?[0-9]{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
\s*
(?:\(\w+\)|\w{3,})? # ASCII representation of timezone.
\s*$
]x or ($mon, $day, $hr, $min, $sec, $tz, $yr) = /^
(\w{1,3}) # month
\s+
([0-9][0-9]?) # day
\s+
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
\s+
(?:([A-Za-z]+)\s+)? # optional timezone
([0-9]+) # year
\s*$ # allow trailing whitespace
/x or ($mon, $day, $yr, $hr, $min, $sec) = /^
(\w{3}) # month
\s+
([0-9][0-9]?) # day
\s+
(?:
([0-9][0-9][0-9][0-9]) | # year
([0-9]{1,2}):([0-9]{2}) # hour:min
(?::([0-9][0-9]))? # optional seconds
)
\s*$
/x or ($yr, $mon, $day, $hr, $min, $sec, $tz) = m[^
([0-9]{4}) # year
[-/]?
([0-9][0-9]?) # numerical month
[-/]?
([0-9][0-9]?) # day
(?:
(?:\s+|[-:Tt]) # separator before clock
([0-9][0-9]?):?([0-9][0-9]) # hour:min
(?::?([0-9][0-9](?:\.[0-9]*)?))? # optional seconds (and fractional)
)? # optional clock
\s*
([-+]?[0-9][0-9]?:?(?:[0-9][0-9])?
|Z|z)? # timezone (Z is "zero meridian", i.e. GMT)
\s*$
]x
() = m[^
([0-9][0-9]?) # day
(?:\s+|[-/])
(\w+) # month
(?:\s+|[-/])
([0-9]+) # year
(?:
(?:\s+|:) # separator before clock
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
)? # optional clock
\s*
([-+]?[0-9]{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
\s*
(?:\(\w+\)|\w{3,})? # ASCII representation of timezone.
\s*$
]x or ($mon, $day, $hr, $min, $sec, $tz, $yr) = /^
(\w{1,3}) # month
\s+
([0-9][0-9]?) # day
\s+
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
\s+
(?:([A-Za-z]+)\s+)? # optional timezone
([0-9]+) # year
\s*$ # allow trailing whitespace
/x or ($mon, $day, $yr, $hr, $min, $sec) = /^
(\w{3}) # month
\s+
([0-9][0-9]?) # day
\s+
(?:
([0-9][0-9][0-9][0-9]) | # year
([0-9]{1,2}):([0-9]{2}) # hour:min
(?::([0-9][0-9]))? # optional seconds
)
\s*$
/x
() = m[^
([0-9][0-9]?) # day
(?:\s+|[-/])
(\w+) # month
(?:\s+|[-/])
([0-9]+) # year
(?:
(?:\s+|:) # separator before clock
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
)? # optional clock
\s*
([-+]?[0-9]{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
\s*
(?:\(\w+\)|\w{3,})? # ASCII representation of timezone.
\s*$
]x or ($mon, $day, $hr, $min, $sec, $tz, $yr) = /^
(\w{1,3}) # month
\s+
([0-9][0-9]?) # day
\s+
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
\s+
(?:([A-Za-z]+)\s+)? # optional timezone
([0-9]+) # year
\s*$ # allow trailing whitespace
/x
MC/DC100%5/5
() = m[^
([0-9][0-9]?) # day
(?:\s+|[-/])
(\w+) # month
(?:\s+|[-/])
([0-9]+) # year
(?:
(?:\s+|:) # separator before clock
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
)? # optional clock
\s*
([-+]?[0-9]{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
\s*
(?:\(\w+\)|\w{3,})? # ASCII representation of timezone.
\s*$
]x or ($mon, $day, $hr, $min, $sec, $tz, $yr) = /^
(\w{1,3}) # month
\s+
([0-9][0-9]?) # day
\s+
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
\s+
(?:([A-Za-z]+)\s+)? # optional timezone
([0-9]+) # year
\s*$ # allow trailing whitespace
/x or ($mon, $day, $yr, $hr, $min, $sec) = /^
(\w{3}) # month
\s+
([0-9][0-9]?) # day
\s+
(?:
([0-9][0-9][0-9][0-9]) | # year
([0-9]{1,2}):([0-9]{2}) # hour:min
(?::([0-9][0-9]))? # optional seconds
)
\s*$
/x or ($yr, $mon, $day, $hr, $min, $sec, $tz) = m[^
([0-9]{4}) # year
[-/]?
([0-9][0-9]?) # numerical month
[-/]?
([0-9][0-9]?) # day
(?:
(?:\s+|[-:Tt]) # separator before clock
([0-9][0-9]?):?([0-9][0-9]) # hour:min
(?::?([0-9][0-9](?:\.[0-9]*)?))? # optional seconds (and fractional)
)? # optional clock
\s*
([-+]?[0-9][0-9]?:?(?:[0-9][0-9])?
|Z|z)? # timezone (Z is "zero meridian", i.e. GMT)
\s*$
]x or ($mon, $day, $yr, $hr, $min, $ampm) = /^
([0-9]{2}) # numerical month
-
([0-9]{2}) # day
-
([0-9]{2,4}) # year
\s+
([0-9][0-9]?):([0-9][0-9])([APap][Mm]) # hour:min AM or PM
\s*$
/x
() = m[^
([0-9][0-9]?) # day
(?:\s+|[-/])
(\w+) # month
(?:\s+|[-/])
([0-9]+) # year
(?:
(?:\s+|:) # separator before clock
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
)? # optional clock
\s*
([-+]?[0-9]{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
\s*
(?:\(\w+\)|\w{3,})? # ASCII representation of timezone.
\s*$
]x
($mon, $day, $hr, $min, $sec, $tz, $yr) = /^
(\w{1,3}) # month
\s+
([0-9][0-9]?) # day
\s+
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
\s+
(?:([A-Za-z]+)\s+)? # optional timezone
([0-9]+) # year
\s*$ # allow trailing whitespace
/x
($mon, $day, $yr, $hr, $min, $sec) = /^
(\w{3}) # month
\s+
([0-9][0-9]?) # day
\s+
(?:
([0-9][0-9][0-9][0-9]) | # year
([0-9]{1,2}):([0-9]{2}) # hour:min
(?::([0-9][0-9]))? # optional seconds
)
\s*$
/x
($yr, $mon, $day, $hr, $min, $sec, $tz) = m[^
([0-9]{4}) # year
[-/]?
([0-9][0-9]?) # numerical month
[-/]?
([0-9][0-9]?) # day
(?:
(?:\s+|[-:Tt]) # separator before clock
([0-9][0-9]?):?([0-9][0-9]) # hour:min
(?::?([0-9][0-9](?:\.[0-9]*)?))? # optional seconds (and fractional)
)? # optional clock
\s*
([-+]?[0-9][0-9]?:?(?:[0-9][0-9])?
|Z|z)? # timezone (Z is "zero meridian", i.e. GMT)
\s*$
]x
($mon, $day, $yr, $hr, $min, $ampm) = /^
([0-9]{2}) # numerical month
-
([0-9]{2}) # day
-
([0-9]{2,4}) # year
\s+
([0-9][0-9]?):([0-9][0-9])([APap][Mm]) # hour:min AM or PM
\s*$
/x
Truth table100%6/6
A or B or C or D or E
A= () = m[^
([0-9][0-9]?) # day
(?:\s+|[-/])
(\w+) # month
(?:\s+|[-/])
([0-9]+) # year
(?:
(?:\s+|:) # separator before clock
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
)? # optional clock
\s*
([-+]?[0-9]{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
\s*
(?:\(\w+\)|\w{3,})? # ASCII representation of timezone.
\s*$
]xB= ($mon, $day, $hr, $min, $sec, $tz, $yr) = /^
(\w{1,3}) # month
\s+
([0-9][0-9]?) # day
\s+
([0-9][0-9]?):([0-9][0-9]) # hour:min
(?::([0-9][0-9]))? # optional seconds
\s+
(?:([A-Za-z]+)\s+)? # optional timezone
([0-9]+) # year
\s*$ # allow trailing whitespace
/xC= ($mon, $day, $yr, $hr, $min, $sec) = /^
(\w{3}) # month
\s+
([0-9][0-9]?) # day
\s+
(?:
([0-9][0-9][0-9][0-9]) | # year
([0-9]{1,2}):([0-9]{2}) # hour:min
(?::([0-9][0-9]))? # optional seconds
)
\s*$
/xD= ($yr, $mon, $day, $hr, $min, $sec, $tz) = m[^
([0-9]{4}) # year
[-/]?
([0-9][0-9]?) # numerical month
[-/]?
([0-9][0-9]?) # day
(?:
(?:\s+|[-:Tt]) # separator before clock
([0-9][0-9]?):?([0-9][0-9]) # hour:min
(?::?([0-9][0-9](?:\.[0-9]*)?))? # optional seconds (and fractional)
)? # optional clock
\s*
([-+]?[0-9][0-9]?:?(?:[0-9][0-9])?
|Z|z)? # timezone (Z is "zero meridian", i.e. GMT)
\s*$
]xE= ($mon, $day, $yr, $hr, $min, $ampm) = /^
([0-9]{2}) # numerical month
-
([0-9]{2}) # day
-
([0-9]{2,4}) # year
\s+
([0-9][0-9]?):([0-9][0-9])([APap][Mm]) # hour:min AM or PM
\s*$
/x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | = /^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ([0-9][0-9]?) # day | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | (?:\s+|[-\/]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | (\w+) # month | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | (?:\s+|[-\/]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ([0-9]+) # year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | (?:\s+|:) # separator before clock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ([0-9][0-9]?):([0-9][0-9]) # hour:min | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | (?::([0-9][0-9]))? # optional seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | )? # optional clock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ([-+]?[0-9]{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | (?:\(\w+\)|\w{3,})? # ASCII representation of timezone. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | \s*$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | /x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # Try the ctime and asctime format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ( $mon, $day, $hr, $min, $sec, $tz, $yr ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | = /^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | (\w{1,3}) # month | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | \s+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ([0-9][0-9]?) # day | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | \s+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ([0-9][0-9]?):([0-9][0-9]) # hour:min | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | (?::([0-9][0-9]))? # optional seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | \s+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | (?:([A-Za-z]+)\s+)? # optional timezone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ([0-9]+) # year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | \s*$ # allow trailing whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | /x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # Then the Unix 'ls -l' date format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ( $mon, $day, $yr, $hr, $min, $sec ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | = /^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | (\w{3}) # month | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | \s+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ([0-9][0-9]?) # day | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | \s+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ([0-9][0-9][0-9][0-9]) | # year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ([0-9]{1,2}):([0-9]{2}) # hour:min | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | (?::([0-9][0-9]))? # optional seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | \s*$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | /x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # ISO 8601 format '1996-02-29 12:00:00 -0100' and variants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | ( $yr, $mon, $day, $hr, $min, $sec, $tz ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | = /^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ([0-9]{4}) # year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | [-\/]? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ([0-9][0-9]?) # numerical month | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | [-\/]? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ([0-9][0-9]?) # day | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | (?:\s+|[-:Tt]) # separator before clock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ([0-9][0-9]?):?([0-9][0-9]) # hour:min | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | (?::?([0-9][0-9](?:\.[0-9]*)?))? # optional seconds (and fractional) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | )? # optional clock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | ([-+]?[0-9][0-9]?:?(?:[0-9][0-9])? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |Z|z)? # timezone (Z is "zero meridian", i.e. GMT) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | \s*$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | /x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # Windows 'dir': '11-12-96 03:52PM' and four-digit year variant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ( $mon, $day, $yr, $hr, $min, $ampm ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | = /^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ([0-9]{2}) # numerical month | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ([0-9]{2}) # day | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ([0-9]{2,4}) # year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | \s+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ([0-9][0-9]?):([0-9][0-9])([APap][Mm]) # hour:min AM or PM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | \s*$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | /x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | || return; # unrecognized format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # Translate month name to number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | $mon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | = $MoY{$mon} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 137 | ▶ | || $MoY{"\u\L$mon"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition94%16/17
$HTTP::Date::MoY{$mon} || $HTTP::Date::MoY{ucfirst lc $mon} || $mon =~ /^[0-9][0-9]?$/ && $mon >= 1 && $mon <= 12 && int $mon || (return)
$HTTP::Date::MoY{$mon} or $HTTP::Date::MoY{ucfirst lc $mon} or $mon =~ /^[0-9][0-9]?$/ and $mon >= 1 and $mon <= 12 and int $mon
$HTTP::Date::MoY{$mon} or $HTTP::Date::MoY{ucfirst lc $mon}
$mon =~ /^[0-9][0-9]?$/ and $mon >= 1 and $mon <= 12 and int $mon
$mon =~ /^[0-9][0-9]?$/ and $mon >= 1 and $mon <= 12
$mon =~ /^[0-9][0-9]?$/ and $mon >= 1
MC/DC83%5/6
$HTTP::Date::MoY{$mon} || $HTTP::Date::MoY{ucfirst lc $mon} || $mon =~ /^[0-9][0-9]?$/ && $mon >= 1 && $mon <= 12 && int $mon || (return)
$HTTP::Date::MoY{$mon}
$HTTP::Date::MoY{ucfirst lc $mon}
$mon =~ /^[0-9][0-9]?$/
$mon >= 1
$mon <= 12
int $mon
Truth table85%6/7
A or B or C and D and E and F
A= $HTTP::Date::MoY{$mon}B= $HTTP::Date::MoY{ucfirst lc $mon}C= $mon =~ /^[0-9][0-9]?$/D= $mon >= 1E= $mon <= 12F= int $mon
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | || ( $mon =~ /^[0-9][0-9]?$/ && $mon >= 1 && $mon <= 12 && int($mon) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # If the year is missing, we assume first date before the current, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # because of the formats we support such dates are mostly present | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # on "ls -l" listings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 133 | ▶ | unless ( defined $yr ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | my $cur_mon; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | ( $cur_mon, $yr ) = (localtime)[ 4, 5 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | $yr += 1900; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | $cur_mon++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | ▶ | $yr-- if $mon > $cur_mon; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | elsif ( length($yr) < 3 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # Find "obvious" year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 23 | my $cur_yr = (localtime)[5] + 1900; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 23 | my $m = $cur_yr % 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 23 | my $tmp = $yr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 23 | $yr += $cur_yr - $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 23 | $m -= $tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 23 | ▶ | $yr += ( $m > 0 ) ? 100 : -100 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | if abs($m) > 50; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # Make sure clock elements are defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 133 | ▶ | $hr = 0 unless defined($hr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 133 | ▶ | $min = 0 unless defined($min); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 133 | ▶ | $sec = 0 unless defined($sec); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # Compensate for AM/PM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 133 | ▶ | if ($ampm) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 17 | $ampm = uc $ampm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 17 | ▶ | $hr = 0 if $hr == 12 && $ampm eq 'AM'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$hr == 12 and $ampm eq "AM"
MC/DC100%2/2
$hr == 12 and $ampm eq "AM"
$hr == 12
$ampm eq "AM"
Truth table100%3/3
A and B
A= $hr == 12B= $ampm eq "AM"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 17 | ▶ | $hr += 12 if $ampm eq 'PM' && $hr != 12; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ampm eq "PM" and $hr != 12
MC/DC100%2/2
$ampm eq "PM" and $hr != 12
$ampm eq "PM"
$hr != 12
Truth table100%3/3
A and B
A= $ampm eq "PM"B= $hr != 12
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 133 | ▶ | return ( $yr, $mon, $day, $hr, $min, $sec, $tz ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | ▶ | if ( defined $tz ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $tz = "Z" if $tz =~ /^(GMT|UTC?|[-+]?0+)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 2 | $tz = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | return sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | "%04d-%02d-%02d %02d:%02d:%02d%s", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | $yr, $mon, $day, $hr, $min, $sec, $tz | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | sub time2iso (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 14 | ▶ | my $time = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time2iso: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 14 | ▶ | $time = time unless defined $time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 14 | my ( $sec, $min, $hour, $mday, $mon, $year ) = localtime($time); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 14 | sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | "%04d-%02d-%02d %02d:%02d:%02d", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | $year + 1900, $mon + 1, $mday, $hour, $min, $sec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | sub time2isoz (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | ▶ | my $time = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time2isoz: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | ▶ | $time = time unless defined $time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | my ( $sec, $min, $hour, $mday, $mon, $year ) = gmtime($time); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | "%04d-%02d-%02d %02d:%02d:%02dZ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | $year + 1900, $mon + 1, $mday, $hour, $min, $sec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # ABSTRACT: HTTP::Date - date conversion routines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||