DateTime-Lite
view release on metacpan or search on metacpan
lib/DateTime/Lite/PP.pm view on Meta::CPAN
{
$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';
my $target = 'DateTime::Lite::' . $sub;
# Install the PP fallback if either:
# - We are running in pure-Perl mode ($IsPurePerl = 1). This guarantees the
# fallback is in place even if XS loading partially populated the DateTime::Lite::
# namespace with empty XSUB stubs before failing (observed on MSWin32 with
# Strawberry Perl 5.14 to 5.20).
# - The XS version has not populated the glob (normal path).
if( $DateTime::Lite::IsPurePerl || !defined( &{ $target } ) )
{
*{ $target } = __PACKAGE__->can( $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.1
=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 1.046 second using v1.01-cache-2.11-cpan-7fcb06a456a )