DateTime-Lite

 view release on metacpan or  search on metacpan

lib/DateTime/Lite/PP.pm  view on Meta::CPAN

    elsif( $m > 14 )
    {
        $y += ( $adj = ( $m - 3 ) / 12 );
        $m -= 12 * $adj;
    }

    if( $y < 0 )
    {
        $d -= 146097 * ( $adj = ( 399 - $y ) / 400 );
        $y += 400 * $adj;
    }

    $d  += ( $m * 367 - 1094 ) / 12
         + $y % 100 * 1461 / 4
         + ( $y / 100 * 36524 + $y / 400 )
         - 306;
    return( $d );
}

# NOTE: Inject all subs into DateTime::Lite's namespace
my @subs = qw(
    _accumulated_leap_seconds
    _compare_rd
    _day_has_leap_second
    _day_length
    _epoch_to_rd
    _is_leap_year
    _normalize_leap_seconds
    _normalize_nanoseconds
    _normalize_tai_seconds
    _rd2ymd
    _rd_to_epoch
    _seconds_as_components
    _time_as_seconds
    _ymd2rd
);

foreach my $sub ( @subs )
{
    no strict 'refs';
    # Only install the PP fallback if the XS version has not already
    # populated the glob (i.e. we are running in pure-Perl mode).
    *{ 'DateTime::Lite::' . $sub } = __PACKAGE__->can( $sub )
        unless( defined( &{ 'DateTime::Lite::' . $sub } ) );
}

1;
# NOTE: POD
__END__

=encoding utf8

=head1 NAME

DateTime::Lite::PP - Pure-Perl fallback for the DateTime::Lite XS layer

=head1 DESCRIPTION

This module is loaded automatically by L<DateTime::Lite> when the XS shared object cannot be loaded, such as when the distribution was installed without a C compiler, or when the environment variable C<PERL_DATETIME_LITE_PP> is set to a true value.

All functions defined here are injected directly into the C<DateTime::Lite> namespace so that callers see them transparently as methods.

You should not normally load or call this module directly.

=head1 VERSION

    v0.1.0

=head1 SEE ALSO

L<DateTime::Lite>

=head1 AUTHOR

Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>

=head1 COPYRIGHT & LICENSE

Copyright(c) 2026 DEGUEST Pte. Ltd.

All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

=cut



( run in 0.986 second using v1.01-cache-2.11-cpan-39bf76dae61 )