| 1 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||||||
| 2 | # © Copyright 2003-2011 by Alex Peeters [alex.peeters@citap.be] | ||||||||||||||
| 3 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||||||
| 4 | # 2011/mm/dd, v3.002.003, package ASNMTAP::Time | ||||||||||||||
| 5 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||||||
| 6 | |||||||||||||||
| 7 | package ASNMTAP::Time; | ||||||||||||||
| 8 | |||||||||||||||
| 9 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 10 | |||||||||||||||
| 11 | 21 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | 21 | ▶ | use warnings; # Must be used in test mode only. This reduces a little process speed | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | #use diagnostics; # Must be used in test mode only. This reduces a lot of process speed | ||||||||||||||
| 14 | |||||||||||||||
| 15 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 16 | |||||||||||||||
| 17 | 21 | ▶ | use Carp qw(cluck); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 18 | 21 | ▶ | use Date::Calc qw(Add_Delta_Days Add_Delta_YMD Delta_Days Week_of_Year); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 19 | 21 | ▶ | use Time::Local; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 20 | |||||||||||||||
| 21 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 22 | |||||||||||||||
| 23 | 21 | ▶ | use ASNMTAP::Asnmtap qw(%ERRORS); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 24 | |||||||||||||||
| 25 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 26 | |||||||||||||||
| 27 | 21 | ▶ | BEGIN { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 28 | 21 | ▶ | use Exporter (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 29 | |||||||||||||||
| 30 | 21 | @ASNMTAP::Time::ISA = qw(Exporter ASNMTAP::Asnmtap); | |||||||||||||
| 31 | |||||||||||||||
| 32 | 21 | %ASNMTAP::Time::EXPORT_TAGS = (ALL => [ qw(SEC MIN HOUR DAY WEEK | |||||||||||||
| 33 | &get_timeslot | ||||||||||||||
| 34 | &get_yearMonthDay | ||||||||||||||
| 35 | &get_yyyymmddhhmmsswday | ||||||||||||||
| 36 | &get_datetimeSignal &get_datetime | ||||||||||||||
| 37 | &get_logfiledate &get_csvfiledate &get_csvfiletime | ||||||||||||||
| 38 | &get_epoch &get_week &get_wday &get_hour &get_min &get_seconds &get_day &get_month &get_year) ], | ||||||||||||||
| 39 | |||||||||||||||
| 40 | EPOCHTIME => [ qw(SEC MIN HOUR DAY WEEK) ], | ||||||||||||||
| 41 | |||||||||||||||
| 42 | LOCALTIME => [ qw(&get_timeslot | ||||||||||||||
| 43 | &get_yearMonthDay | ||||||||||||||
| 44 | &get_yyyymmddhhmmsswday | ||||||||||||||
| 45 | &get_datetimeSignal &get_datetime | ||||||||||||||
| 46 | &get_logfiledate &get_csvfiledate &get_csvfiletime | ||||||||||||||
| 47 | &get_epoch &get_week &get_wday &get_hour &get_min &get_seconds &get_day &get_month &get_year) ] ); | ||||||||||||||
| 48 | |||||||||||||||
| 49 | 21 | @ASNMTAP::Time::EXPORT_OK = ( @{ $ASNMTAP::Time::EXPORT_TAGS{ALL} } ); | |||||||||||||
| 50 | |||||||||||||||
| 51 | 21 | $ASNMTAP::Time::VERSION = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | |||||||||||||||
| 54 | # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||||||||||||||
| 55 | # Constants = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||||||||||||||
| 56 | # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||||||||||||||
| 57 | |||||||||||||||
| 58 | 21 | ▶ | use constant SEC => 1; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 59 | 21 | ▶ | use constant MIN => SEC * 60; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 60 | 21 | ▶ | use constant HOUR => MIN * 60; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 61 | 21 | ▶ | use constant DAY => HOUR * 24; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 62 | 21 | ▶ | use constant WEEK => DAY * 7; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 63 | |||||||||||||||
| 64 | # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||||||||||||||
| 65 | # Private subs = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||||||||||||||
| 66 | # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||||||||||||||
| 67 | |||||||||||||||
| 68 | 0 | ▶ | sub _checkReadOnly0 { if ( @_ > 0 ) { cluck "Syntax error: Can't change value of read-only function ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } } | ||||||||||||
|
Subroutine
_checkReadOnly0: called CC=2 SCAR=10.5
Branch: 1 branch
| |||||||||||||||
| 69 | 0 | ▶ | sub _checkReadOnly1 { if ( @_ > 1 ) { cluck "Syntax error: Can't change value of read-only function ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } } | ||||||||||||
|
Subroutine
_checkReadOnly1: called CC=2 SCAR=10.5
Branch: 1 branch
| |||||||||||||||
| 70 | 0 | ▶ | sub _checkReadOnly2 { if ( @_ > 2 ) { cluck "Syntax error: Can't change value of read-only function ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } } | ||||||||||||
|
Subroutine
_checkReadOnly2: called CC=2 SCAR=10.5
Branch: 1 branch
| |||||||||||||||
| 71 | |||||||||||||||
| 72 | # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||||||||||||||
| 73 | # Public subs = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||||||||||||||
| 74 | # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||||||||||||||
| 75 | |||||||||||||||
| 76 | # Epochtime: | ||||||||||||||
| 77 | # | ||||||||||||||
| 78 | # To get the current time, Perl has a built-in function called time(). | ||||||||||||||
| 79 | # This simply returns the number of non-leap seconds that have elapsed | ||||||||||||||
| 80 | # since 00:00:00 January 1, 1970 UTC. | ||||||||||||||
| 81 | # | ||||||||||||||
| 82 | # current epochtime equal to time() | ||||||||||||||
| 83 | # | ||||||||||||||
| 84 | # timelocal((localtime)[0,1,2,3,4,5]) = timelocal(localtime) | ||||||||||||||
| 85 | |||||||||||||||
| 86 | # List Element Description: | ||||||||||||||
| 87 | # | ||||||||||||||
| 88 | # localtime() converts the UTC time into the correct values for the local time zone. | ||||||||||||||
| 89 | # | ||||||||||||||
| 90 | # localtime() uses the current time -> localtime(time()) equal to localtime(time) | ||||||||||||||
| 91 | # | ||||||||||||||
| 92 | # (localtime)[0]: sec Seconds after each minute (0 - 59) | ||||||||||||||
| 93 | # (localtime)[1]: min Minutes after each hour (0 - 59) | ||||||||||||||
| 94 | # (localtime)[2]: hour Hour since midnight (0 - 23) | ||||||||||||||
| 95 | # (localtime)[3]: monthday Numeric day of the month (1 - 31) | ||||||||||||||
| 96 | # (localtime)[4]: month Number of months since January (0 - 11) | ||||||||||||||
| 97 | # (localtime)[5]: year Number of years since 1900 | ||||||||||||||
| 98 | # (localtime)[6]: weekday Number of days since Sunday (0 - 6) | ||||||||||||||
| 99 | # (localtime)[7]: yearday Number of days since January 1 (0 - 365) | ||||||||||||||
| 100 | # (localtime)[8]: isdaylight A flag for daylight savings time | ||||||||||||||
| 101 | # | ||||||||||||||
| 102 | # ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime( time() ); | ||||||||||||||
| 103 | |||||||||||||||
| 104 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 105 | |||||||||||||||
| 106 | 2 | ▶ | sub get_timeslot { | ||||||||||||
|
Subroutine
get_timeslot: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 107 | 2 | &_checkReadOnly1; | |||||||||||||
| 108 | |||||||||||||||
| 109 | 2 | my $timeslot; | |||||||||||||
| 110 | |||||||||||||||
| 111 | 2 | ▶ | if (defined $_[0]) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 112 | 1 | $timeslot = timelocal ( 0, (localtime($_[0]))[1,2,3,4,5] ); | |||||||||||||
| 113 | } else { | ||||||||||||||
| 114 | 1 | $timeslot = timelocal ( 0, (localtime)[1,2,3,4,5] ); | |||||||||||||
| 115 | } | ||||||||||||||
| 116 | |||||||||||||||
| 117 | 2 | return ( $timeslot ); | |||||||||||||
| 118 | } | ||||||||||||||
| 119 | |||||||||||||||
| 120 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 121 | |||||||||||||||
| 122 | 2 | ▶ | sub get_yearMonthDay { | ||||||||||||
|
Subroutine
get_yearMonthDay: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 123 | 2 | &_checkReadOnly1; | |||||||||||||
| 124 | |||||||||||||||
| 125 | 2 | ▶ | if (defined $_[0]) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 126 | 1 | return (sprintf ("%04d%02d%02d", (localtime($_[0]))[5]+1900, (localtime($_[0]))[4]+1, (localtime($_[0]))[3])); | |||||||||||||
| 127 | } else { | ||||||||||||||
| 128 | 1 | return (sprintf ("%04d%02d%02d", (localtime)[5]+1900, (localtime)[4]+1, (localtime)[3])); | |||||||||||||
| 129 | } | ||||||||||||||
| 130 | } | ||||||||||||||
| 131 | |||||||||||||||
| 132 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 133 | |||||||||||||||
| 134 | 1 | ▶ | sub get_yyyymmddhhmmsswday { &_checkReadOnly0; return sprintf ("%04d:%02d:%02d:%02d:%02d:%02d:%d", (localtime)[5]+1900, (localtime)[4]+1, (localtime)[3,2,1,0,6]); } | ||||||||||||
|
Subroutine
get_yyyymmddhhmmsswday: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 135 | |||||||||||||||
| 136 | 1 | ▶ | sub get_datetimeSignal { &_checkReadOnly0; return sprintf ("%04d/%02d/%02d %02d:%02d:%02d", (localtime)[5]+1900, (localtime)[4]+1, (localtime)[3,2,1,0]); } | ||||||||||||
|
Subroutine
get_datetimeSignal: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 137 | 1 | ▶ | sub get_datetime { &_checkReadOnly0; return sprintf ("%02d%02d%02d%02d%02d%02d", (localtime)[5]+1900, (localtime)[4]+1, (localtime)[3,2,1,0]); } | ||||||||||||
|
Subroutine
get_datetime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 138 | |||||||||||||||
| 139 | 1 | ▶ | sub get_logfiledate { &_checkReadOnly0; return sprintf ("%04d%02d%02d", (localtime)[5]+1900, (localtime)[4]+1, (localtime)[3]); } | ||||||||||||
|
Subroutine
get_logfiledate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 140 | 1 | ▶ | sub get_csvfiledate { &_checkReadOnly0; return sprintf ("%04d/%02d/%02d", (localtime)[5]+1900, (localtime)[4]+1, (localtime)[3]); } | ||||||||||||
|
Subroutine
get_csvfiledate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 141 | 1 | ▶ | sub get_csvfiletime { &_checkReadOnly0; return sprintf ("%02d:%02d:%02d", (localtime)[2,1,0]); } | ||||||||||||
|
Subroutine
get_csvfiletime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 142 | |||||||||||||||
| 143 | # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | ||||||||||||||
| 144 | |||||||||||||||
| 145 | 14 | ▶ | sub get_epoch { | ||||||||||||
|
Subroutine
get_epoch: called CC=18 SCAR=50.7
Pod
undocumented
| |||||||||||||||
| 146 | 14 | ▶ | return ( undef ) unless ( defined $_[0] ); &_checkReadOnly2; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 147 | 13 | my ($string, $time) = @_; | |||||||||||||
| 148 | |||||||||||||||
| 149 | 13 | my $delta = 0; | |||||||||||||
| 150 | 13 | ▶ | my $tTime = ( defined $time ? $time : time() ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 151 | 13 | my ($sign, $number, $type) = ( $string =~ /^\s*([+-])\s*(\d+)\s+(sec|min|hour|(?:day|week|month|year))s?\s*$/ ); | |||||||||||||
| 152 | |||||||||||||||
| 153 | 13 | ▶ | if ( defined $type ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 154 | 0 | my $deltaDays = 0; | |||||||||||||
| 155 | 0 | ▶ | my $multiplyer = ($sign eq '+' ? 1 : -1); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 156 | 0 | my $signedNumber = $number * $multiplyer; | |||||||||||||
| 157 | 0 | my ($year, $month, $day) = ( (localtime($tTime))[5]+1900, (localtime($tTime))[4]+1, (localtime($tTime))[3] ); | |||||||||||||
| 158 | |||||||||||||||
| 159 | 0 | for ($type) { | |||||||||||||
| 160 | 0 | ▶ | /^sec$/ && do { $delta = $signedNumber * SEC; last; }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 161 | 0 | ▶ | /^min$/ && do { $delta = $signedNumber * MIN; last; }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 162 | 0 | ▶ | /^hour$/ && do { $delta = $signedNumber * HOUR; last; }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 163 | 0 | ▶ | /^day(?:s)?$/ && do { $delta = $signedNumber * DAY; last; }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 164 | 0 | ▶ | /^week(?:s)?$/ && do { $delta = $signedNumber * WEEK; last; }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 165 | 0 | ▶ | /^month(?:s)?$/ && do { my $dYear = int($number / 12) * $multiplyer; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 166 | 0 | my $dMonth = $number % 12 * $multiplyer; | |||||||||||||
| 167 | 0 | $deltaDays = Delta_Days ( $year, $month, $day, Add_Delta_YMD ( $year, $month, $day, $dYear, $dMonth, 0 ) ); | |||||||||||||
| 168 | 0 | $delta = $deltaDays * DAY; last; }; | |||||||||||||
| 169 | 0 | ▶ | /^year(?:s)?$/ && do { $deltaDays = Delta_Days ($year, $month, $day, ( $year + $signedNumber ), $month, $day); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 170 | 0 | $delta = $deltaDays * DAY; last; }; | |||||||||||||
| 171 | } | ||||||||||||||
| 172 | } elsif ( ($type) = ( $string =~ /^\s*(today|now|tomorrow|yesterday)\s*$/ ) ) { | ||||||||||||||
| 173 | 13 | for ($type) { | |||||||||||||
| 174 | 13 | ▶ | /^today|now$/ && do { $delta = 0; last; }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 175 | 0 | ▶ | /^tomorrow$/ && do { $delta += DAY; last; }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 176 | 0 | ▶ | /^yesterday$/ && do { $delta -= DAY; last; }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 177 | } | ||||||||||||||
| 178 | } else { | ||||||||||||||
| 179 | 0 | return ( undef ); | |||||||||||||
| 180 | } | ||||||||||||||
| 181 | |||||||||||||||
| 182 | 13 | return ( $tTime + $delta ); | |||||||||||||
| 183 | } | ||||||||||||||
| 184 | |||||||||||||||
| 185 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 186 | |||||||||||||||
| 187 | 3 | ▶ | sub get_week { | ||||||||||||
|
Subroutine
get_week: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 188 | 3 | ▶ | return ( undef ) unless ( defined $_[0] ); &_checkReadOnly2; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 189 | |||||||||||||||
| 190 | 2 | my $time = get_epoch($_[0], $_[1]); | |||||||||||||
| 191 | 2 | my ($week, $year) = Week_of_Year ( (localtime($time))[5]+1900, (localtime($time))[4]+1, (localtime($time))[3] ); | |||||||||||||
| 192 | 2 | $week = sprintf ("%02d", $week); | |||||||||||||
| 193 | 2 | $year = sprintf ("%04d", $year); | |||||||||||||
| 194 | 2 | return ( $week, $year ); | |||||||||||||
| 195 | } | ||||||||||||||
| 196 | |||||||||||||||
| 197 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 198 | |||||||||||||||
| 199 | 3 | ▶ | sub get_wday { | ||||||||||||
|
Subroutine
get_wday: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 200 | 3 | ▶ | return ( undef ) unless ( defined $_[0] ); &_checkReadOnly2; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 201 | |||||||||||||||
| 202 | 2 | return ( (localtime(get_epoch($_[0], $_[1])))[6] ); | |||||||||||||
| 203 | } | ||||||||||||||
| 204 | |||||||||||||||
| 205 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 206 | |||||||||||||||
| 207 | 2 | ▶ | sub get_hour { | ||||||||||||
|
Subroutine
get_hour: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 208 | 2 | &_checkReadOnly1; | |||||||||||||
| 209 | |||||||||||||||
| 210 | 2 | ▶ | if ( defined $_[0] ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 211 | 1 | return sprintf ("%02d", (localtime($_[0]))[2]); | |||||||||||||
| 212 | } else { | ||||||||||||||
| 213 | 1 | return sprintf ("%02d", (localtime)[2]); | |||||||||||||
| 214 | } | ||||||||||||||
| 215 | } | ||||||||||||||
| 216 | |||||||||||||||
| 217 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 218 | |||||||||||||||
| 219 | 2 | ▶ | sub get_min { | ||||||||||||
|
Subroutine
get_min: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 220 | 2 | &_checkReadOnly1; | |||||||||||||
| 221 | |||||||||||||||
| 222 | 2 | ▶ | if ( defined $_[0] ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 223 | 1 | return sprintf ("%02d", (localtime($_[0]))[1]); | |||||||||||||
| 224 | } else { | ||||||||||||||
| 225 | 1 | return sprintf ("%02d", (localtime)[1]); | |||||||||||||
| 226 | } | ||||||||||||||
| 227 | } | ||||||||||||||
| 228 | |||||||||||||||
| 229 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 230 | |||||||||||||||
| 231 | 2 | ▶ | sub get_seconds { | ||||||||||||
|
Subroutine
get_seconds: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 232 | 2 | &_checkReadOnly1; | |||||||||||||
| 233 | |||||||||||||||
| 234 | 2 | ▶ | if ( defined $_[0] ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 235 | 1 | return sprintf ("%02d", (localtime($_[0]))[0]); | |||||||||||||
| 236 | } else { | ||||||||||||||
| 237 | 1 | return sprintf ("%02d", (localtime)[0]); | |||||||||||||
| 238 | } | ||||||||||||||
| 239 | } | ||||||||||||||
| 240 | |||||||||||||||
| 241 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 242 | |||||||||||||||
| 243 | 3 | ▶ | sub get_day { | ||||||||||||
|
Subroutine
get_day: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 244 | 3 | ▶ | return ( undef ) unless ( defined $_[0] ); &_checkReadOnly2; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 245 | |||||||||||||||
| 246 | 2 | return ( sprintf ("%02d", (localtime(get_epoch($_[0], $_[1])))[3]) ); | |||||||||||||
| 247 | } | ||||||||||||||
| 248 | |||||||||||||||
| 249 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 250 | |||||||||||||||
| 251 | 3 | ▶ | sub get_month { | ||||||||||||
|
Subroutine
get_month: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 252 | 3 | ▶ | return ( undef ) unless ( defined $_[0] ); &_checkReadOnly2; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 253 | |||||||||||||||
| 254 | 2 | return ( sprintf ("%02d", (localtime(get_epoch($_[0], $_[1])))[4] +1) ); | |||||||||||||
| 255 | } | ||||||||||||||
| 256 | |||||||||||||||
| 257 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 258 | |||||||||||||||
| 259 | 3 | ▶ | sub get_year { | ||||||||||||
|
Subroutine
get_year: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 260 | 3 | ▶ | return ( undef ) unless ( defined $_[0] ); &_checkReadOnly2; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 261 | |||||||||||||||
| 262 | 2 | return ( sprintf ("%04d", (localtime(get_epoch($_[0], $_[1])))[5] +1900) ); | |||||||||||||
| 263 | } | ||||||||||||||
| 264 | |||||||||||||||
| 265 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 266 | |||||||||||||||
| 267 | 21 | 1; | |||||||||||||
| 268 | |||||||||||||||
| 269 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||
| 270 | |||||||||||||||
| 271 | __END__ | ||||||||||||||