|  | ############################################################################### |  | ############################################################################### | 
|  | # DateTime.pl                                                                 # |  | # DateTime.pm                                                                 # | 
|  |   |  | # $Date: 01.05.16 $                                                           # | 
|  | ############################################################################### |  | ############################################################################### | 
|  | # YaBB: Yet another Bulletin Board                                            # |  | # YaBB: Yet another Bulletin Board                                            # | 
|  | # Open-Source Community Software for Webmasters                               # |  | # Open-Source Community Software for Webmasters                               # | 
|  | # Version:        YaBB 2.5.2                                                  # |  | # Version:        YaBB 2.6.12                                                 # | 
|  | # Packaged:       October 21, 2012                                            # |  | # Packaged:       January 5, 2016                                             # | 
|  | # Distributed by: http://www.yabbforum.com                                    # |  | # Distributed by: http://www.yabbforum.com                                    # | 
|  | # =========================================================================== # |  | # =========================================================================== # | 
|  | # Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     # |  | # Copyright (c) 2000-2016 YaBB (www.yabbforum.com) - All Rights Reserved.     # | 
|  | # Software by:  The YaBB Development Team                                     # |  | # Software by:  The YaBB Development Team                                     # | 
|  | #               with assistance from the YaBB community.                      # |  | #               with assistance from the YaBB community.                      # | 
|  | ############################################################################### |  | ############################################################################### | 
|  |   |  | no warnings qw(uninitialized once redefine); | 
|  | $datetimeplver = 'YaBB 2.5.2 $Revision: 1.0 $';  |  | use CGI::Carp qw(fatalsToBrowser);  | 
|  |   |  | use English qw(-no_match_vars); | 
|  |   |  | use Time::Local; | 
|  |   |  | our $VERSION = '2.6.12'; | 
|  |   |  |   | 
|  |   |  | $datetimepmver = 'YaBB 2.6.12 $Revision: 1651 $'; | 
|  |   |  |   | 
|  |   |  | @days_rfc = qw( Sun Mon Tue Wed Thu Fri Sat ); | 
|  |   |  |     # for RFC compliant feed time | 
|  |   |  | @months_rfc = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); | 
|  |   |  |   | 
|  | sub calcdifference {    # Input: $date1 $date2 |  | sub calcdifference {    # Input: $date1 $date2 | 
|  |     $result = int( $date2 / 86400 ) - int( $date1 / 86400 ); |  |     $result = int( $date2 / 86400 ) - int( $date1 / 86400 ); | 
|  |   |  |     return $result; | 
|  | } |  | } | 
|  |   |  |   | 
|  | sub timetostring { |  | sub toffs { | 
|  |     my $thedate = $_[0];  |  |     my ($mydate, $forum_default) = @_;  | 
|  |     return 0 if !$thedate;  |  |     my $toffs = 0;  | 
|  |     if ( !$maintxt{'107'} ) { $maintxt{'107'} = "at"; } |  |   | 
|  |   |  |   | 
|  |     # find out what timezone is to be used.  |  |     if ( $iamguest || $forum_default || !${ $uid . $username }{'user_tz'} ) {  | 
|  |     if ($iamguest) {  |  |         $tzname = $default_tz || 'UTC';  | 
|  |         $toffs = $timeoffset; |  |   | 
|  |         $toffs += |  |   | 
|  |           ( localtime( $thedate + ( 3600 * $toffs ) ) )[8] ? $dstoffset : 0; |  |   | 
|  |     } |  |     } | 
|  |     else { |  |     else { | 
|  |         $toffs = ${ $uid . $username }{'timeoffset'};  |  |         $tzname = ${ $uid . $username }{'user_tz'};  | 
|  |         $toffs += |  |   | 
|  |           ( localtime( $thedate + ( 3600 * $toffs ) ) )[8] |  |   | 
|  |           ? ${ $uid . $username }{'dsttimeoffset'} |  |   | 
|  |           : 0; |  |   | 
|  |     } |  |     } | 
|  |   |  |   | 
|  |   |  |     eval { | 
|  |   |  |           require DateTime; | 
|  |   |  |           require DateTime::TimeZone; | 
|  |   |  |     }; | 
|  |   |  |     if( !$EVAL_ERROR ) { | 
|  |   |  |         DateTime->import(); | 
|  |   |  |         DateTime::TimeZone->import(); | 
|  |   |  |         if ( $tzname eq 'local' ) { | 
|  |   |  |             $tzname = 'UTC'; | 
|  |   |  |         } | 
|  |   |  |         my $tz = DateTime::TimeZone->new(name => $tzname); | 
|  |   |  |         my $now = DateTime->from_epoch( 'epoch' => $mydate ); | 
|  |   |  |         $toffs = $tz->offset_for_datetime($now); | 
|  |   |  |     } | 
|  |   |  |     elsif ( $EVAL_ERROR ) { | 
|  |   |  |         if ( $tzname eq 'local' ) { | 
|  |   |  |             $toffs = $timeoffset; | 
|  |   |  |             $toffs += | 
|  |   |  |               ( localtime( $mydate + ( 3600 * $toffs ) ) )[8] ? $dstoffset : 0; | 
|  |   |  |             $toffs = 3600 * $toffs; | 
|  |   |  |         } | 
|  |   |  |         else { $toffs = 0; } | 
|  |   |  |     } | 
|  |   |  |     else { $toffs = 0; } | 
|  |   |  |   | 
|  |   |  |     return $toffs; | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub timetostring { | 
|  |   |  |     my ($thedate) = @_; | 
|  |   |  |     return 0 if !$thedate; | 
|  |   |  |     if ( !$maintxt{'107'} ) { $maintxt{'107'} = 'at'; } | 
|  |   |  |     my $toffs = 0; | 
|  |   |  |     if ($enabletz) { | 
|  |   |  |         $toffs = toffs($thedate); | 
|  |   |  |     } | 
|  |   |  |     my $newtime =  $thedate + $toffs; | 
|  |   |  |   | 
|  |     ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, undef ) = |  |     ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, undef ) = | 
|  |       gmtime( $thedate + ( 3600 * $toffs ) ); |  |       gmtime( $newtime ); | 
|  |     $sec  = sprintf( "%02d", $sec );  |  |     $sec  = sprintf '%02d', $sec;  | 
|  |     $min  = sprintf( "%02d", $min );  |  |     $min  = sprintf '%02d', $min;  | 
|  |     $hour = sprintf( "%02d", $hour );  |  |     $hour = sprintf '%02d', $hour;  | 
|  |     $mday = sprintf( "%02d", $mday );  |  |     $mday = sprintf '%02d', $mday;  | 
|  |     $mon_num  = $mon + 1; |  |     $mon_num  = $mon + 1; | 
|  |     $mon_num  = sprintf( "%02d", $mon_num );  |  |     $mon_num  = sprintf '%02d', $mon_num;  | 
|  |     $year     = 1900 + $year; |  |     $year     = 1900 + $year; | 
|  |     $saveyear = ( $year % 100 ); |  |     $saveyear = ( $year % 100 ); | 
|  |     $saveyear = sprintf( "%02d", $saveyear );  |  |     $saveyear = sprintf '%02d', $saveyear;  | 
|  |     return "$mon_num/$mday/$saveyear $maintxt{'107'} $hour\:$min\:$sec"; |  |     return "$mon_num/$mday/$saveyear $maintxt{'107'} $hour\:$min\:$sec"; | 
|  | } |  | } | 
|  |   |  |   | 
|  | # generic string-to-time converter |  | # generic string-to-time converter | 
|  |   |  |   | 
|  | sub stringtotime { |  | sub stringtotime { | 
|  |     unless ( $_[0] ) { return 0; }  |  |     my ($spvar) = @_;  | 
|  |     require Time::Local;  |  |     if ( !$spvar ) { return 0; }  | 
|  |     import Time::Local 'timelocal';  |  |     $splitvar = $spvar;  | 
|  |     $splitvar = $_[0]; |  |   | 
|  |   |  |   | 
|  | # receive standard format yabb date/time string. |  | # receive standard format yabb date/time string. | 
|  | # allow for oddities thrown up from y1 , with full year / single digit day/month |  | # allow for oddities thrown up from y1 , with full year / single digit day/month | 
|  |     $splitvar =~  |  |     my $amonth = 1;  | 
|  |       m~(\d{1,2})\/(\d{1,2})\/(\d{2,4}).*?(\d{1,2})\:(\d{1,2})\:(\d{1,2})~;  |  |     my $aday   = 1;  | 
|  |     $amonth = int($1) || 1;  |  |     my $ayear  = 0;  | 
|  |     $aday   = int($2) || 1;  |  |     my $ahour  = 0;  | 
|  |     $ayear  = int($3) || 0; |  |     my $amin   = 0; | 
|  |     $ahour  = int($4) || 0; |  |     my $asec   = 0; | 
|  |     $amin   = int($5) || 0; |  |   | 
|  |     $asec   = int($6) || 0;  |  |     if ( $splitvar =~  | 
|  |   |  |         m/(\d{1,2})\/(\d{1,2})\/(\d{2,4}).*?(\d{1,2})\:(\d{1,2})\:(\d{1,2})/sm ) | 
|  |   |  |     { | 
|  |   |  |         $amonth = int $1; | 
|  |   |  |         $aday   = int $2; | 
|  |   |  |         $ayear  = int $3; | 
|  |   |  |         $ahour  = int $4; | 
|  |   |  |         $amin   = int $5; | 
|  |   |  |         $asec   = int $6; | 
|  |   |  |     } | 
|  |   |  |     elsif ( $splitvar =~ m/(\d{1,2})\/(\d{1,2})\/(\d{2,4})/sm ) { | 
|  |   |  |         $amonth = int $1; | 
|  |   |  |         $aday   = int $2; | 
|  |   |  |         $ayear  = int $3; | 
|  |   |  |         $ahour  = 0; | 
|  |   |  |         $amin   = 0; | 
|  |   |  |         $asec   = 0; | 
|  |   |  |     } | 
|  |   |  |   | 
|  |     # Uses 1904 and 2036 as the default dates, as both are leap years. |  |     # Uses 1904 and 2036 as the default dates, as both are leap years. | 
|  |     # If we used the real extremes (1901 and 2038) - there would be problems |  |     # If we used the real extremes (1901 and 2038) - there would be problems | 
|  |     # As timelocal dies if you provide 29th Feb as a date in a non-leap year |  |     # As time dies if you provide 29th Feb as a date in a non-leap year | 
|  |     # Using leap years as the default years prevents this from happening. |  |     # Using leap years as the default years prevents this from happening. | 
|  |   |  |   | 
|  |     if    ( $ayear >= 36 && $ayear <= 99 ) { $ayear += 1900; } |  |     if    ( $ayear >= 36 && $ayear <= 99 ) { $ayear += 1900; } | 
|  |     elsif ( $ayear >= 00 && $ayear <= 35 ) { $ayear += 2000; } |  |     elsif ( $ayear >= 00 && $ayear <= 35 ) { $ayear += 2000; } | 
|  |     if    ( $ayear < 1904 ) { $ayear = 1904; } |  |     if    ( $ayear < 1904 ) { $ayear = 1904; } | 
|  |     elsif ( $ayear > 2036 ) { $ayear = 2036; } |  |     elsif ( $ayear > 2036 ) { $ayear = 2036; } | 
|  |   |  |   | 
|  |     if    ( $amonth < 1 )  { $amonth = 0; } |  |     if    ( $amonth < 1 )  { $amonth = 0; } | 
|  |     elsif ( $amonth > 12 ) { $amonth = 11; } |  |     elsif ( $amonth > 12 ) { $amonth = 11; } | 
|  |     else                   { --$amonth; } |  |     else                   { --$amonth; } | 
|  |   |  |   | 
|  |     if ( $amonth == 3 || $amonth == 5 || $amonth == 8 || $amonth == 10 ) { |  |     if ( $amonth == 3 || $amonth == 5 || $amonth == 8 || $amonth == 10 ) { | 
|  |         $max_days = 30; |  |         $max_days = 30; | 
|  |     } |  |     } | 
|  |     elsif ( $amonth == 1 && $ayear % 4 == 0 ) { $max_days = 29; } |  |     elsif ( $amonth == 1 && $ayear % 4 == 0 ) { $max_days = 29; } | 
|  |     elsif ( $amonth == 1 && $ayear % 4 != 0 ) { $max_days = 28; } |  |     elsif ( $amonth == 1 && $ayear % 4 != 0 ) { $max_days = 28; } | 
|  |     else                                      { $max_days = 31; } |  |     else                                      { $max_days = 31; } | 
|  |     if ( $aday > $max_days ) { $aday = $max_days; } |  |     if ( $aday > $max_days ) { $aday = $max_days; } | 
|  |   |  |   | 
|  |     if    ( $ahour < 1 )  { $ahour = 0; } |  |     if    ( $ahour < 1 )  { $ahour = 0; } | 
|  |     elsif ( $ahour > 23 ) { $ahour = 23; } |  |     elsif ( $ahour > 23 ) { $ahour = 23; } | 
|  |     if    ( $amin < 1 )   { $amin  = 0; } |  |     if    ( $amin < 1 )   { $amin  = 0; } | 
|  |     elsif ( $amin > 59 )  { $amin  = 59; } |  |     elsif ( $amin > 59 )  { $amin  = 59; } | 
|  |     if    ( $asec < 1 )   { $asec  = 0; } |  |     if    ( $asec < 1 )   { $asec  = 0; } | 
|  |     elsif ( $asec > 59 )  { $asec  = 59; } |  |     elsif ( $asec > 59 )  { $asec  = 59; } | 
|  |   |  |   | 
|  |     return ( timelocal( $asec, $amin, $ahour, $aday, $amonth, $ayear ) ); |  |     return ( timegm( $asec, $amin, $ahour, $aday, $amonth, $ayear ) ); | 
|  | } |  | } | 
|  |   |  |   | 
|  | sub timeformat { |  | sub timeformat { | 
|  |     my $oldformat     = $_[0];  |  |     my ( $oldformat, $dontusetoday, $use_rfc, $forum_default, $lower ) = @_;  | 
|  |     my $dontusetoday  = $_[1]; |  |   | 
|  |     my $use_rfc       = $_[2];  |  |     # use forum default time and format  | 
|  |     my $forum_default = $_[3];    # use forum default time and format |  |   | 
|  |   |  |   | 
|  |     $mytimeselected = |  |     $mytimeselected = | 
|  |       ( $forum_default || !${ $uid . $username }{'timeselect'} ) |  |       ( $forum_default || !${ $uid . $username }{'timeselect'} ) | 
|  |       ? $timeselected |  |       ? $timeselected | 
|  |       : ${ $uid . $username }{'timeselect'}; |  |       : ${ $uid . $username }{'timeselect'}; | 
|  |   |  |   | 
|  |     chomp $oldformat; |  |     chomp $oldformat; | 
|  |     return if !$oldformat; |  |     return if !$oldformat; | 
|  |   |  |   | 
|  |     @days_rfc = ( 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ) |  |   | 
|  |       ;                           # for RFC compliant feed time |  |   | 
|  |     @months_rfc = ( |  |   | 
|  |         'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', |  |   | 
|  |         'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'  |  |   | 
|  |     ); |  |   | 
|  |   |  |   | 
|  |     # find out what timezone is to be used. |  |     # find out what timezone is to be used. | 
|  |     if ( $iamguest || $forum_default ) {  |  |     my $toffs = 0;  | 
|  |         $toffs = $timeoffset;  |  |     if ( $enabletz) {  | 
|  |         $toffs +=  |  |         $toffs = toffs($oldformat, $forum_default);  | 
|  |           ( localtime( $oldformat + ( 3600 * $toffs ) ) )[8] ? $dstoffset : 0; |  |   | 
|  |     } |  |   | 
|  |     else { |  |   | 
|  |         $toffs = ${ $uid . $username }{'timeoffset'}; |  |   | 
|  |         $toffs += |  |   | 
|  |           ( localtime( $oldformat + ( 3600 * $toffs ) ) )[8] |  |   | 
|  |           ? ${ $uid . $username }{'dsttimeoffset'} |  |   | 
|  |           : 0; |  |   | 
|  |     } |  |     } | 
|  |   |  |     my $mynewtime =  $oldformat + $toffs; | 
|  |   |  |   | 
|  |     my ( |  |     my ( | 
|  |         $newsecond, $newminute,  $newhour,    $newday, $newmonth, |  |         $newsecond, $newminute,  $newhour,    $newday, $newmonth, | 
|  |         $newyear,   $newweekday, $newyearday, undef  |  |         $newyear,   $newweekday, $newyearday, $newoff  | 
|  |     ) = gmtime( $oldformat + ( 3600 * $toffs ) ); |  |     ) = gmtime( $mynewtime ); | 
|  |     $newmonth++; |  |     $newmonth++; | 
|  |     $newyear += 1900; |  |     $newyear += 1900; | 
|  |   |  |   | 
|  |     # Calculate number of full weeks this year |  |     # Calculate number of full weeks this year | 
|  |     $newweek = int( ( $newyearday + 1 - $newweekday ) / 7 ) + 1; |  |     $newweek = int( ( $newyearday + 1 - $newweekday ) / 7 ) + 1; | 
|  |   |  |   | 
|  |     # Add 1 if today isn't Saturday |  |     # Add 1 if today isn't Saturday | 
|  |     if ( $newweekday < 6 ) { $newweek = $newweek + 1; } |  |     if ( $newweekday < 6 ) { $newweek = $newweek + 1; } | 
|  |     $newweek = sprintf( "%02d", $newweek );  |  |     $newweek = sprintf '%02d', $newweek;  | 
|  |   |  |   | 
|  |     if ($use_rfc) { |  |     if ($use_rfc) { | 
|  |         $shortday = $days_rfc[$newweekday]; |  |         $shortday = $days_rfc[$newweekday]; | 
|  |     } |  |     } | 
|  |     else { |  |     else { | 
|  |         $shortday = $days_short[$newweekday]; |  |         $shortday = $days_short[$newweekday]; | 
|  |     } |  |     } | 
|  |   |  |   | 
|  |     $longday      = $days[$newweekday]; |  |     $longday      = $days[$newweekday]; | 
|  |     $newmonth     = sprintf( "%02d", $newmonth );  |  |     $newmonth     = sprintf '%02d', $newmonth;  | 
|  |     $newshortyear = ( $newyear % 100 ); |  |     $newshortyear = ( $newyear % 100 ); | 
|  |     $newshortyear = sprintf( "%02d", $newshortyear );  |  |     $newshortyear = sprintf '%02d', $newshortyear;  | 
|  |     if ( $mytimeselected != 4 && $mytimeselected != 8 ) { |  |     if ( $mytimeselected != 4 && $mytimeselected != 8 ) { | 
|  |         $newday = sprintf( "%02d", $newday );  |  |         $newday = sprintf '%02d', $newday;  | 
|  |     } |  |     } | 
|  |     $newhour   = sprintf( "%02d", $newhour );  |  |     $newhour   = sprintf '%02d', $newhour;  | 
|  |     $newminute = sprintf( "%02d", $newminute );  |  |     $newminute = sprintf '%02d', $newminute;  | 
|  |     $newsecond = sprintf( "%02d", $newsecond );  |  |     $newsecond = sprintf '%02d', $newsecond;  | 
|  |   |  |   | 
|  |     $newtime = $newhour . ":" . $newminute . ":" . $newsecond; |  |     $newtime = $newhour . q{:} . $newminute . q{:} . $newsecond; | 
|  |   |  |   | 
|  |     ( undef, undef, undef, undef, undef, $yy, undef, $yd, undef ) = |  |     ( undef, undef, undef, undef, undef, $yy, undef, $yd, undef ) = | 
|  |       gmtime( $date + ( 3600 * $toffs ) ); |  |       gmtime( $date + $toffs ); | 
|  |     $yy += 1900; |  |     $yy += 1900; | 
|  |   |  |   | 
|  |     $daytxt = undef;    # must be a global variable |  |     $daytxt = undef;    # must be a global variable | 
|  |     unless ($dontusetoday) { |  |     if ( !$dontusetoday ) { | 
|  |         if ( $yd == $newyearday && $yy == $newyear ) { |  |         if ( $yd == $newyearday && $yy == $newyear ) { | 
|  |   |  |   | 
|  |             # today |  |             # today | 
|  |             $daytxt = qq~<b>$maintxt{'769'}</b>~; |  |             $daytxt = qq~<b>$maintxt{'769'}</b>~; | 
|  |   |  |             if ( $lower && $maintxt{'769l'} ) { | 
|  |   |  |                 $daytxt = qq~<b>$maintxt{'769l'}</b>~; | 
|  |   |  |             } | 
|  |         } |  |         } | 
|  |         elsif ( |  |         elsif ( | 
|  |             ( ( $yd - 1 ) == $newyearday && $yy == $newyear ) |  |             ( ( $yd - 1 ) == $newyearday && $yy == $newyear ) | 
|  |             || (   $yd == 0 |  |             || (   $yd == 0 | 
|  |                 && $newday == 31 |  |                 && $newday == 31 | 
|  |                 && $newmonth == 12 |  |                 && $newmonth == 12 | 
|  |                 && ( $yy - 1 ) == $newyear ) |  |                 && ( $yy - 1 ) == $newyear ) | 
|  |           ) |  |           ) | 
|  |         { |  |         { | 
|  |   |  |   | 
|  |             # yesterday || yesterday, over a year end. |  |             # yesterday || yesterday, over a year end. | 
|  |             $daytxt = qq~<b>$maintxt{'769a'}</b>~; |  |             $daytxt = qq~<b>$maintxt{'769a'}</b>~; | 
|  |   |  |             if ( $lower && $maintxt{'769al'} ) { | 
|  |   |  |                 $daytxt = qq~<b>$maintxt{'769al'}</b>~; | 
|  |   |  |             } | 
|  |         } |  |         } | 
|  |     } |  |     } | 
|  |   |  |   | 
|  |     if ( !$maintxt{'107'} ) { $maintxt{'107'} = $admin_txt{'107'}; } |  |     if ( !$maintxt{'107'} ) { $maintxt{'107'} = $admin_txt{'107'}; } | 
|  |   |  |     my @timform = ( | 
|  |     if ( $mytimeselected == 7 ) {  |  |         q{},  | 
|  |         $mytimeformat = ${ $uid . $username }{'timeformat'};  |  |         time_1( $daytxt, $newday, $newmonth, $newyear, $newtime ),  | 
|  |         if ( $mytimeformat =~ m/hh/ ) { $hourstyle = 12; }  |  |         time_2( $daytxt, $newday, $newmonth, $newyear, $newtime ),  | 
|  |         if ( $mytimeformat =~ m/HH/ ) { $hourstyle = 24; }  |  |         time_3( $daytxt, $newday, $newmonth, $newyear, $newtime ),  | 
|  |         $mytimeformat =~ s/\@/$maintxt{'107'}/g;  |  |         time_4( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute, $lower ),  | 
|  |         $mytimeformat =~ s/mm/$newminute/g;  |  |         time_5( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute ),  | 
|  |         $mytimeformat =~ s/ss/$newsecond/g;  |  |         time_6( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute ),  | 
|  |         $mytimeformat =~ s/ww/$newweek/g;  |  |         q{},  | 
|  |   |  |         time_8( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute ), | 
|  |         if ( $mytimeformat =~ m/\+/ ) {  |  |     );  | 
|  |             if ( $newday > 10 && $newday < 20 ) { |  |     foreach my $i ( 1 .. 8 ) { | 
|  |                 $dayext = "<sup>$timetxt{'4'}</sup>";  |  |         if ( $mytimeselected == $i ) {  | 
|  |             }  |  |             $newformat = $timform[$i];  | 
|  |             elsif ( $newday % 10 == 1 ) { |  |   | 
|  |                 $dayext = "<sup>$timetxt{'1'}</sup>"; |  |   | 
|  |             } |  |   | 
|  |             elsif ( $newday % 10 == 2 ) { |  |   | 
|  |                 $dayext = "<sup>$timetxt{'2'}</sup>"; |  |   | 
|  |             } |  |   | 
|  |             elsif ( $newday % 10 == 3 ) { |  |   | 
|  |                 $dayext = "<sup>$timetxt{'3'}</sup>"; |  |   | 
|  |             } |  |   | 
|  |             else { |  |   | 
|  |                 $dayext = "<sup>$timetxt{'4'}</sup>"; |  |   | 
|  |             } |  |   | 
|  |         } |  |         } | 
|  |         if ( $hourstyle == 12 ) {  |  |     }  | 
|  |             $ampm = $newhour > 11 ? 'pm' : 'am';  |  |     return $newformat;  | 
|  |             $newhour2 = $newhour % 12 || 12;  |  | }  | 
|  |             $mytimeformat =~ s/hh/$newhour2/g; |  |   | 
|  |             $mytimeformat =~ s/\#/$ampm/g; |  |   | 
|  |         } |  |   | 
|  |         elsif ( $hourstyle == 24 ) { |  |   | 
|  |             $mytimeformat =~ s/HH/$newhour/g; |  |   | 
|  |         } |  |   | 
|  |         if ( $daytxt eq '' ) { |  |   | 
|  |             $mytimeformat =~ s/YYYY/$newyear/g; |  |   | 
|  |             $mytimeformat =~ s/YY/$newshortyear/g; |  |   | 
|  |             $mytimeformat =~ s/SDT/$shortday/g; |  |   | 
|  |             $mytimeformat =~ s/LDT/$longday/g; |  |   | 
|  |             $mytimeformat =~ s/DD/$newday/g; |  |   | 
|  |             $mytimeformat =~ s/D/$newday/g; |  |   | 
|  |             $mytimeformat =~ s/\+/$dayext/g; |  |   | 
|  |             if ( $mytimeformat =~ m/MM/ ) { |  |   | 
|  |   |  |   | 
|  |                 if ($use_rfc) { |  | sub timeformatcal { | 
|  |                     $mytimeformat =~ s/MM/$months_rfc[$newmonth-1]/g;  |  |     my ( $mynewtime, $usetoday ) = @_;  | 
|  |                 } |  |   | 
|  |                 else { $mytimeformat =~ s/MM/$months[$newmonth-1]/g; }  |  |     # use forum default time and format  | 
|  |             } |  |   | 
|  |             elsif ( $mytimeformat =~ m/M/ ) { |  |   | 
|  |                 $mytimeformat =~ s/M/$newmonth/g; |  |   | 
|  |             } |  |   | 
|  |         } |  |   | 
|  |         else { |  |   | 
|  |             $mytimeformat =~ s/SDT/$shortday/g; |  |   | 
|  |             $mytimeformat =~ s/LDT/$longday/g; |  |   | 
|  |             $mytimeformat =~ s/DD/$daytxt/g; |  |   | 
|  |             $mytimeformat =~ s/D/$daytxt/g; |  |   | 
|  |             $mytimeformat =~ s/YY//g; |  |   | 
|  |             $mytimeformat =~ s/M//g; |  |   | 
|  |             $mytimeformat =~ s/\/\///g; |  |   | 
|  |             $mytimeformat =~ s/\+//g; |  |   | 
|  |         } |  |   | 
|  |         if ( $newisdst && ${ $uid . $username }{'dsttimeoffset'} != 0 ) { |  |   | 
|  |             $mytimeformat =~ s/\*/$maintxt{'dst'}/g; |  |   | 
|  |         } |  |   | 
|  |         else { |  |   | 
|  |             $mytimeformat =~ s/\*//g; |  |   | 
|  |         } |  |   | 
|  |   |  |   | 
|  |         # Timezones |  |   | 
|  |         my $timezone = ${ $uid . $username }{'timeoffset'}; |  |   | 
|  |         my $sign     = '+'; |  |   | 
|  |         if ( $timezone < 0 ) { $sign = '-'; } |  |   | 
|  |         $timezone = $sign . sprintf( "%04u", abs($timezone) * 100 ); |  |   | 
|  |         $mytimeformat =~ s/zzz/$timezone/g; |  |   | 
|  |         $mytimeformat =~ s/  / /g; |  |   | 
|  |         $mytimeformat =~ s/[\n\r]//g; |  |   | 
|  |   |  |   | 
|  |         $newformat = $mytimeformat;  |  |     $mytimeselected =  | 
|  |   |  |       ( $forum_default || !${ $uid . $username }{'timeselect'} ) | 
|  |   |  |       ? $timeselected | 
|  |   |  |       : ${ $uid . $username }{'timeselect'}; | 
|  |   |  |   | 
|  |   |  |     chomp $mynewtime; | 
|  |   |  |     return if !$mynewtime; | 
|  |   |  |   | 
|  |   |  |     # find out what timezone is to be used. | 
|  |   |  |     my $toffs = 0; | 
|  |   |  |     my ( | 
|  |   |  |         $newsecond, $newminute,  $newhour,    $newday, $newmonth, | 
|  |   |  |         $newyear,   $newweekday, $newyearday, $newoff | 
|  |   |  |     ) = gmtime( $mynewtime ); | 
|  |   |  |     $newmonth++; | 
|  |   |  |     $newyear += 1900; | 
|  |   |  |   | 
|  |   |  |     # Calculate number of full weeks this year | 
|  |   |  |     $newweek = int( ( $newyearday + 1 - $newweekday ) / 7 ) + 1; | 
|  |   |  |   | 
|  |   |  |     # Add 1 if today isn't Saturday | 
|  |   |  |     if ( $newweekday < 6 ) { $newweek = $newweek + 1; } | 
|  |   |  |     $newweek = sprintf '%02d', $newweek; | 
|  |   |  |   | 
|  |   |  |     if ($use_rfc) { | 
|  |   |  |         $shortday = $days_rfc[$newweekday]; | 
|  |     } |  |     } | 
|  |     elsif ( $mytimeselected == 1 ) { |  |     else { | 
|  |         $newformat =  |  |         $shortday = $days_short[$newweekday];  | 
|  |           $daytxt |  |   | 
|  |           ? qq~$daytxt $maintxt{'107'} $newtime~ |  |   | 
|  |           : qq~$newmonth/$newday/$newshortyear $maintxt{'107'} $newtime~; |  |   | 
|  |     } |  |     } | 
|  |     elsif ( $mytimeselected == 2 ) { |  |   | 
|  |         $newformat =  |  |     $longday      = $days[$newweekday];  | 
|  |           $daytxt  |  |     $newmonth     = sprintf '%02d', $newmonth;  | 
|  |           ? qq~$daytxt $maintxt{'107'} $newtime~  |  |     $newshortyear = ( $newyear % 100 );  | 
|  |           : qq~$newday.$newmonth.$newshortyear $maintxt{'107'} $newtime~;  |  |     $newshortyear = sprintf '%02d', $newshortyear;  | 
|  |   |  |     if ( $mytimeselected != 4 && $mytimeselected != 8 ) { | 
|  |   |  |         $newday = sprintf '%02d', $newday; | 
|  |     } |  |     } | 
|  |     elsif ( $mytimeselected == 3 ) {  |  |     $newhour   = sprintf '%02d', $newhour;  | 
|  |         $newformat =  |  |     $newminute = sprintf '%02d', $newminute;  | 
|  |           $daytxt  |  |     $newsecond = sprintf '%02d', $newsecond;  | 
|  |           ? qq~$daytxt $maintxt{'107'} $newtime~ |  |   | 
|  |           : qq~$newday.$newmonth.$newyear $maintxt{'107'} $newtime~;  |  |     $newtime = $newhour . q{:} . $newminute . q{:} . $newsecond;  | 
|  |   |  |   | 
|  |   |  |     if ( $enabletz) { | 
|  |   |  |         $toffs = toffs($date); | 
|  |     } |  |     } | 
|  |     elsif ( $mytimeselected == 4 || $mytimeselected == 8 ) {  |  |     ( undef, undef, undef, undef, undef, $yy, undef, $yd, undef ) =  | 
|  |         $ampm = $newhour > 11 ? 'pm' : 'am';  |  |       gmtime( $date + $toffs );  | 
|  |         $newhour2 = $newhour % 12 || 12;  |  |     $yy += 1900;  | 
|  |         if   ($use_rfc) { $newmonth2 = $months_rfc[ $newmonth - 1 ]; }  |  |     $daytxt = undef;    # must be a global variable  | 
|  |         else            { $newmonth2 = $months[ $newmonth - 1 ]; }  |  |     if ( $usetoday == 1 ) {  | 
|  |         if ( $newday > 10 && $newday < 20 ) {  |  |         $myleap = IsLeap($yy);  | 
|  |             $newday2 = "<sup>$timetxt{'4'}</sup>";  |  |         if ( $yd == $newyearday && $yy == $newyear ) {  | 
|  |         } |  |   | 
|  |         elsif ( $newday % 10 == 1 ) {  |  |             # today  | 
|  |             $newday2 = "<sup>$timetxt{'1'}</sup>";  |  |             $daytxt = qq~<b>$maintxt{'769'}</b>~;  | 
|  |         } |  |   | 
|  |         elsif ( $newday % 10 == 2 ) {  |  |         }  | 
|  |             $newday2 = "<sup>$timetxt{'2'}</sup>";  |  |         elsif (  | 
|  |         }  |  |             ( ( $yd - 1 ) == $newyearday && $yy == $newyear )  | 
|  |         elsif ( $newday % 10 == 3 ) {  |  |             || (   $yd == 0  | 
|  |             $newday2 = "<sup>$timetxt{'3'}</sup>";  |  |                 && $newday == 31  | 
|  |         }  |  |                 && $newmonth == 12  | 
|  |         else {  |  |                 && ( $yy - 1 ) == $newyear )  | 
|  |             $newday2 = "<sup>$timetxt{'4'}</sup>";  |  |           )  | 
|  |         }  |  |         {  | 
|  |         if ( $mytimeselected == 4 ) { |  |   | 
|  |             $newformat =  |  |             # yesterday || yesterday, over a year end.  | 
|  |               $daytxt  |  |             $daytxt = qq~<b>$maintxt{'769a'}</b>~;  | 
|  |               ? qq~$daytxt $maintxt{'107'} $newhour2:$newminute$ampm~  |  |         }  | 
|  |               : qq~$newmonth2 $newday$newday2, $newyear $maintxt{'107'} $newhour2:$newminute$ampm~;  |  |         elsif (  | 
|  |         }  |  |             ( ( $yd + 1 ) == $newyearday && $yy == $newyear )  | 
|  |         else {  |  |             || (   $yd == ( 365 + $myleap )  | 
|  |             $newformat =  |  |                 && $newday == 1  | 
|  |               $daytxt  |  |                 && $newmonth == 0  | 
|  |               ? qq~$daytxt $maintxt{'107'} $newhour2:$newminute$ampm~  |  |                 && ( $yy + 1 ) == $newyear )  | 
|  |               : qq~$newday$newday2 $newmonth2, $newyear $maintxt{'107'} $newhour2:$newminute$ampm~;  |  |           )  | 
|  |         }  |  |         {  | 
|  |     } |  |   | 
|  |     elsif ( $mytimeselected == 5 ) {  |  |             # tomorrow || tomorrow, over a year end.  | 
|  |         $ampm = $newhour > 11 ? 'pm' : 'am';  |  |             $daytxt = qq~<b>$maintxt{'769b'}</b>~;  | 
|  |         $newhour2 = $newhour % 12 || 12;  |  |         }  | 
|  |         $newformat = |  |   | 
|  |           $daytxt |  |   | 
|  |           ? qq~$daytxt $maintxt{'107'} $newhour2:$newminute$ampm~ |  |   | 
|  |           : qq~$newmonth/$newday/$newshortyear $maintxt{'107'} $newhour2:$newminute$ampm~; |  |   | 
|  |     } |  |     } | 
|  |     elsif ( $mytimeselected == 6 ) { |  |   | 
|  |         if   ($use_rfc) { $newmonth2 = $months_rfc[ $newmonth - 1 ]; } |  |     if ( !$maintxt{'107'} ) { $maintxt{'107'} = $admin_txt{'107'}; } | 
|  |         else            { $newmonth2 = $months[ $newmonth - 1 ]; }  |  |     my @timform = (  | 
|  |         $newformat =  |  |         q{},  | 
|  |           $daytxt  |  |         time_1( $daytxt, $newday, $newmonth, $newyear, $newtime ),  | 
|  |           ? qq~$daytxt $maintxt{'107'} $newhour:$newminute~  |  |         time_2( $daytxt, $newday, $newmonth, $newyear, $newtime ),  | 
|  |           : qq~$newday. $newmonth2 $newyear $maintxt{'107'} $newhour:$newminute~;  |  |         time_3( $daytxt, $newday, $newmonth, $newyear, $newtime ),  | 
|  |   |  |         time_4( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute ), | 
|  |   |  |         time_5( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute ), | 
|  |   |  |         time_6( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute ), | 
|  |   |  |         q{}, | 
|  |   |  |         time_8( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute ), | 
|  |   |  |     ); | 
|  |   |  |     foreach my $i ( 1 .. 8 ) { | 
|  |   |  |         if ( $mytimeselected == $i ) { | 
|  |   |  |             $newformat = $timform[$i]; | 
|  |   |  |         } | 
|  |     } |  |     } | 
|  |     $newformat;  |  |     $newformat = dtonly($newformat);  | 
|  |   |  |     return $newformat; | 
|  | } |  | } | 
|  |   |  |   | 
|  | sub CalcAge { |  | sub CalcAge { | 
|  |     &timetostring($date);  |  |     my ( $user, $act ) = @_;  | 
|  |     my ( $usermonth, $userday, $useryear, $act ); |  |   | 
|  |     my $user = $_[0];  |  |     timetostring($date);  | 
|  |     my $act  = $_[1];  |  |     my ( $usermonth, $userday, $useryear );  | 
|  |   |  |   | 
|  |     if ( ${ $uid . $user }{'bday'} ne '' ) { |  |     if ( ${ $uid . $user }{'bday'} ne q{} ) { | 
|  |         ( $usermonth, $userday, $useryear ) = |  |         ( $usermonth, $userday, $useryear ) = | 
|  |           split( /\//, ${ $uid . $user }{'bday'} );  |  |           split /\//xsm, ${ $uid . $user }{'bday'};  | 
|  |   |  |   | 
|  |         if ( $act eq "calc" ) { |  |         if ( $act eq 'calc' ) { | 
|  |             if ( length( ${ $uid . $user }{'bday'} ) <= 2 ) { |  |             if ( length( ${ $uid . $user }{'bday'} ) <= 2 ) { | 
|  |                 $age = ${ $uid . $user }{'bday'}; |  |                 $age = ${ $uid . $user }{'bday'}; | 
|  |             } |  |             } | 
|  |             else { |  |             else { | 
|  |                 $age = $year - $useryear; |  |                 $age = $year - $useryear; | 
|  |                 if ( $usermonth > $mon_num |  |                 if ( $usermonth > $mon_num | 
|  |                     || ( $usermonth == $mon_num && $userday > $mday ) ) |  |                     || ( $usermonth == $mon_num && $userday > $mday ) ) | 
|  |                 { |  |                 { | 
|  |                     --$age; |  |                     --$age; | 
|  |                 } |  |                 } | 
|  |             } |  |             } | 
|  |         } |  |         } | 
|  |         if ( $act eq "parse" ) { |  |         if ( $act eq 'parse' ) { | 
|  |             if ( length( ${ $uid . $user }{'bday'} ) <= 2 ) { return; } |  |             if ( length( ${ $uid . $user }{'bday'} ) <= 2 ) { return; } | 
|  |             $umonth = $usermonth; |  |             $umonth = $usermonth; | 
|  |             $uday   = $userday; |  |             $uday   = $userday; | 
|  |             $uyear  = $useryear; |  |             $uyear  = $useryear; | 
|  |         } |  |         } | 
|  |         if ( $act eq "isbday" ) { |  |         if ( $act eq 'isbday' ) { | 
|  |             if ( $usermonth == $mon_num && $userday == $mday ) { |  |             if ( $usermonth == $mon_num && $userday == $mday ) { | 
|  |                 $isbday = "yes";  |  |                 $isbday = 'yes';  | 
|  |             } |  |             } | 
|  |         } |  |         } | 
|  |     } |  |     } | 
|  |     else { |  |     else { | 
|  |         $age    = "";  |  |         $age    = q{};  | 
|  |         $isbday = "";  |  |         $isbday = q{};  | 
|  |     } |  |     } | 
|  |   |  |     return; | 
|  | } |  | } | 
|  |   |  |   | 
|  | sub NumberFormat { |  | sub NumberFormat { | 
|  |     my ( $decimal, $fraction ) = split( /\./, $_[0] );  |  |     my ($inp) = @_;  | 
|  |   |  |     my ( $decimal, $fraction ) = split /\./xsm, $inp; | 
|  |     my $tmpforumformat = $forumnumberformat || 1; |  |     my $tmpforumformat = $forumnumberformat || 1; | 
|  |     my $numberformat = ${ $uid . $username }{'numberformat'} || $tmpforumformat; |  |     my $numberformat = ${ $uid . $username }{'numberformat'} || $tmpforumformat; | 
|  |     if ( $numberformat == 1 ) {  |  |     my @septor =  | 
|  |         $separator = "";  |  |       ( [ q{}, q{}, q{,}, q{.}, q{ }, ], [ q{.}, q{,}, q{.}, q{,}, q{,}, ], );  | 
|  |         $decimalpt = "."; |  |   | 
|  |     }  |  |     foreach my $i ( 0 .. 4 ) {  | 
|  |     elsif ( $numberformat == 2 ) {  |  |         $dra = $septor[0]->[$i];  | 
|  |         $separator = "";  |  |         $drb = $septor[1]->[$i];  | 
|  |         $decimalpt = ",";  |  |         if ( $numberformat == ( $i + 1 ) ) {  | 
|  |     }  |  |             $separator = $dra;  | 
|  |     elsif ( $numberformat == 3 ) {  |  |             $decimalpt = $drb;  | 
|  |         $separator = ",";  |  |         }  | 
|  |         $decimalpt = "."; |  |   | 
|  |     } |  |   | 
|  |     elsif ( $numberformat == 4 ) { |  |   | 
|  |         $separator = "."; |  |   | 
|  |         $decimalpt = ","; |  |   | 
|  |     } |  |   | 
|  |     elsif ( $numberformat == 5 ) { |  |   | 
|  |         $separator = " "; |  |   | 
|  |         $decimalpt = ","; |  |   | 
|  |     } |  |     } | 
|  |     if ( $decimal =~ m/\d{4,}/ ) { |  |     if ( $decimal =~ m/\d{4,}/sm ) { | 
|  |         $decimal = reverse $decimal; |  |         $decimal = reverse $decimal; | 
|  |         $decimal =~ s/(\d{3})/$1$separator/g;  |  |         $decimal =~ s/(\d{3})/$1$separator/gsm;  | 
|  |         $decimal = reverse $decimal; |  |         $decimal = reverse $decimal; | 
|  |         $decimal =~ s/^(\.|\,| )//;  |  |         $decimal =~ s/^(\.|\,| )//sm;  | 
|  |     } |  |     } | 
|  |     $newnumber = $decimal; |  |     $newnumber = $decimal; | 
|  |     if ($fraction) { |  |     if ($fraction) { | 
|  |         $newnumber .= "$decimalpt$fraction"; |  |         $newnumber .= "$decimalpt$fraction"; | 
|  |     } |  |     } | 
|  |     return $newnumber; |  |     return $newnumber; | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub time_1 { | 
|  |   |  |     my ( $daytxt, $newday, $newmonth, $newyear, $newtime ) = @_; | 
|  |   |  |     $newformat = | 
|  |   |  |       $daytxt | 
|  |   |  |       ? qq~$daytxt $maintxt{'107'} $newtime~ | 
|  |   |  |       : qq~$newmonth/$newday/$newshortyear $maintxt{'107'} $newtime~; | 
|  |   |  |   | 
|  |   |  |     return $newformat; | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub time_2 { | 
|  |   |  |     my ( $daytxt, $newday, $newmonth, $newyear, $newtime ) = @_; | 
|  |   |  |     $newformat = | 
|  |   |  |       $daytxt | 
|  |   |  |       ? qq~$daytxt $maintxt{'107'} $newtime~ | 
|  |   |  |       : qq~$newday.$newmonth.$newshortyear $maintxt{'107'} $newtime~; | 
|  |   |  |   | 
|  |   |  |     return $newformat; | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub time_3 { | 
|  |   |  |     my ( $daytxt, $newday, $newmonth, $newyear, $newtime ) = @_; | 
|  |   |  |     $newformat = | 
|  |   |  |       $daytxt | 
|  |   |  |       ? qq~$daytxt $maintxt{'107'} $newtime~ | 
|  |   |  |       : qq~$newday.$newmonth.$newyear $maintxt{'107'} $newtime~; | 
|  |   |  |   | 
|  |   |  |     return $newformat; | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub time_4 { | 
|  |   |  |     my ( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute, $lower ) = @_; | 
|  |   |  |     $ampm = $newhour > 11 ? 'pm' : 'am'; | 
|  |   |  |     $newhour2 = $newhour % 12 || 12; | 
|  |   |  |     if ( !@months_m ) { @months_m = @months; } | 
|  |   |  |     if   ($use_rfc) { $newmonth2 = $months_rfc[ $newmonth - 1 ]; } | 
|  |   |  |     elsif ( $lower ) { $newmonth2 = $months_m[ $newmonth - 1 ]; } | 
|  |   |  |     else             { $newmonth2 = $months[ $newmonth - 1 ]; } | 
|  |   |  |     $newday2 = "$timetxt{'4'}"; | 
|  |   |  |     if ( $newday > 10 && $newday < 20 ) { | 
|  |   |  |         $newday2 = "$timetxt{'4'}"; | 
|  |   |  |     } | 
|  |   |  |     else { | 
|  |   |  |         foreach my $i ( 1 .. 3 ) { | 
|  |   |  |             if ( $newday % 10 == $i ) { | 
|  |   |  |                 $newday2 = qq~$timetxt{$i}~; | 
|  |   |  |             } | 
|  |   |  |         } | 
|  |   |  |     } | 
|  |   |  |     $newformat = | 
|  |   |  |           $daytxt | 
|  |   |  |           ? qq~$daytxt $maintxt{'107'} $newhour2:$newminute$ampm~ | 
|  |   |  |           : qq~$newmonth2$maintxt{'770'} $newday$newday2, $newyear $maintxt{'107'} $newhour2:$newminute$ampm~; | 
|  |   |  |   | 
|  |   |  |     return $newformat; | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub time_5 { | 
|  |   |  |     my ( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute ) = @_; | 
|  |   |  |     $ampm = $newhour > 11 ? 'pm' : 'am'; | 
|  |   |  |     $newhour2 = $newhour % 12 || 12; | 
|  |   |  |     $newformat = | 
|  |   |  |       $daytxt | 
|  |   |  |       ? qq~$daytxt $maintxt{'107'} $newhour2:$newminute$ampm~ | 
|  |   |  |       : qq~$newmonth/$newday/$newshortyear $maintxt{'107'} $newhour2:$newminute$ampm~; | 
|  |   |  |   | 
|  |   |  |     return ($newformat); | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub time_6 { | 
|  |   |  |     my ( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute ) = @_; | 
|  |   |  |     if   ($use_rfc) { $newmonth2 = $months_rfc[ $newmonth - 1 ]; } | 
|  |   |  |     elsif ( @months_m )            { $newmonth2 = $months_m[ $newmonth - 1 ]; } | 
|  |   |  |     else            { $newmonth2 = $months[ $newmonth - 1 ]; } | 
|  |   |  |     $newformat = | 
|  |   |  |       $daytxt | 
|  |   |  |       ? qq~$daytxt $maintxt{'107'} $newhour:$newminute~ | 
|  |   |  |       : qq~$newday. $newmonth2$maintxt{'770a'} $newyear $maintxt{'107'} $newhour:$newminute~; | 
|  |   |  |   | 
|  |   |  |     return $newformat; | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub time_8 { | 
|  |   |  |     my ( $daytxt, $newday, $newmonth, $newyear, $newhour, $newminute ) = @_; | 
|  |   |  |     $ampm = $newhour > 11 ? 'pm' : 'am'; | 
|  |   |  |     $newhour2 = $newhour % 12 || 12; | 
|  |   |  |     if   ($use_rfc) { $newmonth2 = $months_rfc[ $newmonth - 1 ]; } | 
|  |   |  |     elsif ( @months_m )            { $newmonth2 = $months_m[ $newmonth - 1 ]; } | 
|  |   |  |     else            { $newmonth2 = $months[ $newmonth - 1 ]; } | 
|  |   |  |     $newday2 = "$timetxt{'4'}"; | 
|  |   |  |     if ( $newday > 10 && $newday < 20 ) { | 
|  |   |  |         $newday2 = "$timetxt{'4'}"; | 
|  |   |  |     } | 
|  |   |  |     else { | 
|  |   |  |         foreach my $i ( 1 .. 3 ) { | 
|  |   |  |             if ( $newday % 10 == $i ) { | 
|  |   |  |                 $newday2 = qq~$timetxt{$i}~; | 
|  |   |  |             } | 
|  |   |  |         } | 
|  |   |  |     } | 
|  |   |  |     $newformat = | 
|  |   |  |       $daytxt | 
|  |   |  |       ? qq~$daytxt $maintxt{'107'} $newhour2:$newminute$ampm~ | 
|  |   |  |       : qq~$newday$newday2 $newmonth2$maintxt{'770a'}, $newyear $maintxt{'107'} $newhour2:$newminute$ampm~; | 
|  |   |  |   | 
|  |   |  |     return $newformat; | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub dtonly { | 
|  |   |  |     my ($newformat) = @_; | 
|  |   |  |     if ( $newformat =~ m/\A(.*?)\s*$maintxt{'107'}\s*(.*?)\Z/ism ) { | 
|  |   |  |         $dateonly = $1; | 
|  |   |  |     } | 
|  |   |  |   | 
|  |   |  |     return ($dateonly); | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub tmonly { | 
|  |   |  |     my ($newformat) = @_; | 
|  |   |  |     if ( $newformat =~ m/\A(.*?)\s*$maintxt{'107'}\s*(.*?)\Z/ism ) { | 
|  |   |  |         $timeonly = $2; | 
|  |   |  |     } | 
|  |   |  |   | 
|  |   |  |     return ($timeonly); | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub bdayno_year { | 
|  |   |  |     my ($newformat) = @_; | 
|  |   |  |     $date_noyear = $newformat; | 
|  |   |  |     if ( $mytimeselected == 4 || $mytimeselected == 8 ) { | 
|  |   |  |         ( $date_noyear, undef ) = split /\,/xsm, $newformat; | 
|  |   |  |     } | 
|  |   |  |     elsif ( $mytimeselected == 1 || $mytimeselected == 5 ) { | 
|  |   |  |         @date_noyear = split /\//xsm, $newformat; | 
|  |   |  |         $date_noyear = qq~$date_noyear[0]~ . q{/} . qq~$date_noyear[1]~; | 
|  |   |  |     } | 
|  |   |  |     elsif ( $mytimeselected == 2 || $mytimeselected == 3 ) { | 
|  |   |  |         @date_noyear = split /[.]/xsm, $newformat; | 
|  |   |  |         $date_noyear = qq~$date_noyear[0]~ . q{/} . qq~$date_noyear[1]~; | 
|  |   |  |     } | 
|  |   |  |     elsif ( $mytimeselected == 6 ) { | 
|  |   |  |         @date_noyear = split / /sm, $newformat; | 
|  |   |  |         $date_noyear = qq~$date_noyear[0] $date_noyear[1]~; | 
|  |   |  |     } | 
|  |   |  |   | 
|  |   |  |     return ($date_noyear); | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub IsLeap {   | 
|  |   |  |    my ($year ) = @_; | 
|  |   |  |    return 0 if $year % 4; | 
|  |   |  |    return 1 if $year % 100; | 
|  |   |  |    return 0 if $year % 400; | 
|  |   |  |    return 1; | 
|  |   |  | } | 
|  |   |  |   | 
|  |   |  | sub ctbtime { | 
|  |   |  |     my ( | 
|  |   |  |         $newsecond, $newminute,  $newhour,    $newday, $newmonth, | 
|  |   |  |         $newyear,   $newweekday, $newyearday, $newoff | 
|  |   |  |     ) = gmtime( $date ); | 
|  |   |  |     $newyear += 1900; | 
|  |   |  |     $shortday = $days_rfc[$newweekday]; | 
|  |   |  |     $shortmon = $months_rfc[$newmonth]; | 
|  |   |  |     $newhour   = sprintf '%02d', $newhour; | 
|  |   |  |     $newminute = sprintf '%02d', $newminute; | 
|  |   |  |     $newsecond = sprintf '%02d', $newsecond; | 
|  |   |  |     $newmin = $newhour . q{:} . $newminute . q{:} . $newsecond; | 
|  |   |  |     $newtime = qq~$shortday, $newday $shortmon $newyear $newmin UTC~; | 
|  |   |  |   | 
|  |   |  |     return $newtime; | 
|  | } |  | } | 
|  |   |  |   | 
|  | 1; |  | 1; | 
|  |   |  |   |