Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

125
database/perl/vendor/lib/Time/Moment.pm vendored Normal file
View File

@@ -0,0 +1,125 @@
package Time::Moment;
use strict;
use warnings;
use Carp qw[];
BEGIN {
our $VERSION = '0.44';
require XSLoader; XSLoader::load(__PACKAGE__, $VERSION);
}
BEGIN {
unless (exists &Time::Moment::now) {
require Time::HiRes;
eval sprintf <<'EOC', __FILE__;
# line 17 %s
# expects normalized tm values; algorithm is only valid for tm year's [1, 199]
sub timegm {
my ($y, $d, $h, $m, $s) = @_[5,7,2,1,0];
return ((1461 * --$y >> 2) + $d - 25202) * 86400 + $h * 3600 + $m * 60 + $s;
}
sub now {
@_ == 1 || Carp::croak(q/Usage: Time::Moment->now()/);
my ($class) = @_;
my ($sec, $usec) = Time::HiRes::gettimeofday();
my $offset = int((timegm(localtime($sec)) - $sec) / 60);
return $class->from_epoch($sec, $usec * 1000)
->with_offset_same_instant($offset);
}
sub now_utc {
@_ == 1 || Carp::croak(q/Usage: Time::Moment->now_utc()/);
my ($class) = @_;
my ($sec, $usec) = Time::HiRes::gettimeofday();
return $class->from_epoch($sec, $usec * 1000);
}
EOC
die $@ if $@;
}
}
BEGIN {
delete @Time::Moment::{qw(timegm)};
}
sub __as_DateTime {
my ($tm) = @_;
return DateTime->from_epoch(
epoch => $tm->epoch,
time_zone => $tm->strftime('%Z'),
)->set_nanosecond($tm->nanosecond);
}
sub __as_Time_Piece {
my ($tm) = @_;
return scalar Time::Piece::gmtime($tm->epoch);
}
sub DateTime::__as_Time_Moment {
my ($dt) = @_;
(!$dt->time_zone->is_floating)
or Carp::croak(q/Cannot coerce an instance of DateTime in the 'floating' /
.q/time zone to an instance of Time::Moment/);
return Time::Moment->from_epoch($dt->epoch, $dt->nanosecond)
->with_offset_same_instant(int($dt->offset / 60));
}
sub Time::Piece::__as_Time_Moment {
my ($tp) = @_;
return Time::Moment->from_epoch($tp->epoch)
->with_offset_same_instant(int($tp->tzoffset / 60));
}
sub STORABLE_freeze {
my ($self, $cloning) = @_;
return if $cloning;
return pack 'nnNNN', 0x544D, $self->offset, $self->utc_rd_values;
}
sub STORABLE_thaw {
my ($self, $cloning, $packed) = @_;
return if $cloning;
(length($packed) == 16 && vec($packed, 0, 16) == 0x544D) # TM
or die(q/Cannot deserialize corrupted data/); # Don't replace die with Carp!
my ($offset, $rdn, $sod, $nos) = unpack 'xxnNNN', $packed;
$offset = ($offset & 0x7FFF) - 0x8000 if ($offset & 0x8000);
my $seconds = ($rdn - 719163) * 86400 + $sod;
$$self = ${ ref($self)->from_epoch($seconds, $nos)
->with_offset_same_instant($offset) };
}
sub TO_JSON {
return $_[0]->to_string;
}
sub TO_CBOR {
# Use the standard tag for date/time string; see RFC 7049 Section 2.4.1
return CBOR::XS::tag(0, $_[0]->to_string);
}
sub FREEZE {
return $_[0]->to_string;
}
sub THAW {
my ($class, undef, $string) = @_;
return $class->from_string($string);
}
# Alias
*with_offset = \&with_offset_same_instant;
# used by DateTime::TimeZone
sub utc_year {
return $_[0]->with_offset_same_instant(0)->year;
}
1;

1951
database/perl/vendor/lib/Time/Moment.pod vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,171 @@
package Time::Moment::Adjusters;
use strict;
use warnings;
use Carp qw[];
BEGIN {
our $VERSION = '0.44';
our @EXPORT_OK = qw[ NextDayOfWeek
NextOrSameDayOfWeek
PreviousDayOfWeek
PreviousOrSameDayOfWeek
FirstDayOfWeekInMonth
LastDayOfWeekInMonth
NthDayOfWeekInMonth
WesternEasterSunday
OrthodoxEasterSunday
NearestMinuteInterval ];
our %EXPORT_TAGS = (
all => [ @EXPORT_OK ],
);
require Exporter;
*import = \&Exporter::import;
}
sub NextDayOfWeek {
@_ == 1 or Carp::croak(q<Usage: NextDayOfWeek(day)>);
my ($day) = @_;
($day >= 1 && $day <= 7)
or Carp::croak(q<Parameter 'day' is out of the range [1, 7]>);
return sub {
my ($tm) = @_;
return $tm->plus_days(($day - $tm->day_of_week + 6) % 7 + 1);
};
}
sub NextOrSameDayOfWeek {
@_ == 1 or Carp::croak(q<Usage: NextOrSameDayOfWeek(day)>);
my ($day) = @_;
($day >= 1 && $day <= 7)
or Carp::croak(q<Parameter 'day' is out of the range [1, 7]>);
return sub {
my ($tm) = @_;
return $tm->plus_days(($day - $tm->day_of_week) % 7);
};
}
sub PreviousDayOfWeek {
@_ == 1 or Carp::croak(q<Usage: PreviousDayOfWeek(day)>);
my ($day) = @_;
($day >= 1 && $day <= 7)
or Carp::croak(q<Parameter 'day' is out of the range [1, 7]>);
return sub {
my ($tm) = @_;
return $tm->minus_days(($tm->day_of_week - $day + 6) % 7 + 1);
};
}
sub PreviousOrSameDayOfWeek {
@_ == 1 or Carp::croak(q<Usage: PreviousOrSameDayOfWeek(day)>);
my ($day) = @_;
($day >= 1 && $day <= 7)
or Carp::croak(q<Parameter 'day' is out of the range [1, 7]>);
return sub {
my ($tm) = @_;
return $tm->minus_days(($tm->day_of_week - $day) % 7);
};
}
sub FirstDayOfWeekInMonth {
@_ == 1 or Carp::croak(q<Usage: FirstDayOfWeekInMonth(day)>);
my ($day) = @_;
($day >= 1 && $day <= 7)
or Carp::croak(q<Parameter 'day' is out of the range [1, 7]>);
return sub {
my ($tm) = @_;
$tm = $tm->with_day_of_month(1);
return $tm->plus_days(($day - $tm->day_of_week) % 7);
};
}
sub LastDayOfWeekInMonth {
@_ == 1 or Carp::croak(q<Usage: LastDayOfWeekInMonth(day)>);
my ($day) = @_;
($day >= 1 && $day <= 7)
or Carp::croak(q<Parameter 'day' is out of the range [1, 7]>);
return sub {
my ($tm) = @_;
$tm = $tm->at_last_day_of_month;
return $tm->minus_days(($tm->day_of_week - $day) % 7);
};
}
sub NthDayOfWeekInMonth {
@_ == 2 or Carp::croak(q<Usage: NthDayOfWeekInMonth(ordinal, day)>);
my ($ordinal, $day) = @_;
($ordinal >= -4 && $ordinal <= 4 && $ordinal != 0)
or Carp::croak(q<Parameter 'ordinal' is out of the range [-4, -1] u [1, 4]>);
($day >= 1 && $day <= 7)
or Carp::croak(q<Parameter 'day' is out of the range [1, 7]>);
if ($ordinal > 0) {
my $days = 7 * --$ordinal;
return sub {
my ($tm) = @_;
$tm = $tm->with_day_of_month(1);
return $tm->plus_days($days + ($day - $tm->day_of_week) % 7);
};
}
else {
my $days = 7 * ++$ordinal;
return sub {
my ($tm) = @_;
$tm = $tm->at_last_day_of_month;
return $tm->plus_days($days - ($tm->day_of_week - $day) % 7);
};
}
}
sub WesternEasterSunday {
@_ == 0 or Carp::croak(q<Usage: WesternEasterSunday()>);
return sub {
my ($tm) = @_;
return $tm->with_rdn(Time::Moment::Internal::western_easter_sunday($tm->year));
};
}
sub OrthodoxEasterSunday {
@_ == 0 or Carp::croak(q<Usage: OrthodoxEasterSunday()>);
return sub {
my ($tm) = @_;
return $tm->with_rdn(Time::Moment::Internal::orthodox_easter_sunday($tm->year));
};
}
sub NearestMinuteInterval {
@_ == 1 or Carp::croak(q<Usage: NearestMinuteInterval(interval)>);
my ($interval) = @_;
($interval >= 1 && $interval <= 1440)
or Carp::croak(q<Parameter 'interval' is out of the range [1, 1440]>);
my $msec = $interval * 60 * 1000;
my $mid = int(($msec + 1) / 2);
return sub {
my ($tm) = @_;
my $msod = $msec * int(($tm->millisecond_of_day + $mid) / $msec);
return $tm->with_millisecond_of_day($msod);
};
}
1;

View File

@@ -0,0 +1,143 @@
=encoding utf-8
=head1 NAME
Time::Moment::Adjusters - Adjusters for Time::Moment
=head1 SYNOPSIS
$adjuster = NextDayOfWeek($day);
$adjuster = NextOrSameDayOfWeek($day);
$adjuster = PreviousDayOfWeek($day);
$adjuster = PreviousOrSameDayOfWeek($day);
$adjuster = FirstDayOfWeekInMonth($day);
$adjuster = LastDayOfWeekInMonth($day);
$adjuster = NthDayOfWeekInMonth($ordinal, $day);
$adjuster = WesternEasterSunday();
$adjuster = OrthodoxEasterSunday();
$adjuster = NearestMinuteInterval($interval);
=head1 DESCRIPTION
C<Time::Moment::Adjusters> provides adjusters. An adjuster is a CODE reference
invoked with an instance of Time::Moment and is expected to return an instance
of Time::Moment.
=head1 FUNCTIONS
=head2 NextDayOfWeek
$adjuster = NextDayOfWeek($day);
The C<$adjuster> adjusts the date to the next occurrence of the given I<day>
of the week [1=Monday, 7=Sunday] that is after the date.
=head2 NextOrSameDayOfWeek
$adjuster = NextOrSameDayOfWeek($day);
The C<$adjuster> adjusts the date to the next occurrence of the given I<day>
of the week [1=Monday, 7=Sunday]. If the date already falls on the given
I<day> of the week it's unaltered.
=head2 PreviousDayOfWeek
$adjuster = PreviousDayOfWeek($day);
The C<$adjuster> adjusts the date to the previous occurrence of the given
I<day> of the week [1=Monday, 7=Sunday] that is before the date.
=head2 PreviousOrSameDayOfWeek
$adjuster = PreviousOrSameDayOfWeek($day);
The C<$adjuster> adjusts the date to the previous occurrence of the given
I<day> of the week [1=Monday, 7=Sunday]. If the date already falls on the
given I<day> of the week it's unaltered.
=head2 FirstDayOfWeekInMonth
$adjuster = FirstDayOfWeekInMonth($day);
The C<$adjuster> adjusts the date to the first occurrence of the given
I<day> of the week [1=Monday, 7=Sunday] within the month.
=head2 LastDayOfWeekInMonth
$adjuster = LastDayOfWeekInMonth($day);
The C<$adjuster> adjusts the date to the last occurrence of the given
I<day> of the week [1=Monday, 7=Sunday] within the month.
=head2 NthDayOfWeekInMonth
$adjuster = NthDayOfWeekInMonth($ordinal, $day);
The C<$adjuster> adjusts the date to the given I<ordinal> I<day> of
the week within the month.
B<Parameters:>
=over 4
=item ordinal
The I<ordinal> of the week within the month [-4, -1] [1, 4].
=item day
The I<day> of the week [1=Monday, 7=Sunday].
=back
=head2 WesternEasterSunday
$adjuster = WesternEasterSunday();
The C<$adjuster> adjusts the date to the Western Easter Sunday. The Western
computus is based on the Gregorian calendar.
=head2 OrthodoxEasterSunday
$adjuster = OrthodoxEasterSunday();
The C<$adjuster> adjusts the date to the Orthodox Easter Sunday. The Orthodox
computus is based on the Julian calendar with the Julian date converted to
the equivalent Gregorian date.
=head2 NearestMinuteInterval
$adjuster = NearestMinuteInterval($interval);
The C<$adjuster> adjusts the time of day to the nearest minute of the given
minute I<interval> [1, 1440].
Given an minute interval of C<30>:
T10:14:59 => T10:00:00
T10:15:00 => T10:30:00
T10:29:59 => T10:30:00
T23:55:00 => T00:00:00 (midnight of the following day)
=head1 EXPORTS
None by default. All functions can be exported using the C<:all> tag or
individually.
=head1 AUTHOR
Christian Hansen C<chansen@cpan.org>
=head1 COPYRIGHT
Copyright 2015-2017 by Christian Hansen.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

291
database/perl/vendor/lib/Time/Zone.pm vendored Normal file
View File

@@ -0,0 +1,291 @@
package Time::Zone;
=head1 NAME
Time::Zone -- miscellaneous timezone manipulations routines
=head1 SYNOPSIS
use Time::Zone;
print tz2zone();
print tz2zone($ENV{'TZ'});
print tz2zone($ENV{'TZ'}, time());
print tz2zone($ENV{'TZ'}, undef, $isdst);
$offset = tz_local_offset();
$offset = tz_offset($TZ);
=head1 DESCRIPTION
This is a collection of miscellaneous timezone manipulation routines.
C<tz2zone()> parses the TZ environment variable and returns a timezone
string suitable for inclusion in L<date(1)>-like output. It opionally takes
a timezone string, a time, and a is-dst flag.
C<tz_local_offset()> determins the offset from GMT time in seconds. It
only does the calculation once.
C<tz_offset()> determines the offset from GMT in seconds of a specified
timezone.
C<tz_name()> determines the name of the timezone based on its offset
=head1 AUTHORS
Graham Barr <gbarr@pobox.com>
David Muir Sharnoff <muir@idiom.com>
Paul Foley <paul@ascent.com>
=cut
require 5.002;
require Exporter;
use Carp;
use strict;
use vars qw(@ISA @EXPORT $VERSION @tz_local);
@ISA = qw(Exporter);
@EXPORT = qw(tz2zone tz_local_offset tz_offset tz_name);
$VERSION = "2.24";
# Parts stolen from code by Paul Foley <paul@ascent.com>
sub tz2zone (;$$$)
{
my($TZ, $time, $isdst) = @_;
use vars qw(%tzn_cache);
$TZ = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : ''
unless $TZ;
# Hack to deal with 'PST8PDT' format of TZ
# Note that this can't deal with all the esoteric forms, but it
# does recognize the most common: [:]STDoff[DST[off][,rule]]
if (! defined $isdst) {
my $j;
$time = time() unless $time;
($j, $j, $j, $j, $j, $j, $j, $j, $isdst) = localtime($time);
}
if (defined $tzn_cache{$TZ}->[$isdst]) {
return $tzn_cache{$TZ}->[$isdst];
}
if ($TZ =~ /^
( [^:\d+\-,] {3,} )
( [+-] ?
\d {1,2}
( : \d {1,2} ) {0,2}
)
( [^\d+\-,] {3,} )?
/x
) {
my $dsttz = defined($4) ? $4 : $1;
$TZ = $isdst ? $dsttz : $1;
$tzn_cache{$TZ} = [ $1, $dsttz ];
} else {
$tzn_cache{$TZ} = [ $TZ, $TZ ];
}
return $TZ;
}
sub tz_local_offset (;$)
{
my ($time) = @_;
$time = time() unless $time;
my (@l) = localtime($time);
my $isdst = $l[8];
if (defined($tz_local[$isdst])) {
return $tz_local[$isdst];
}
$tz_local[$isdst] = &calc_off($time);
return $tz_local[$isdst];
}
sub calc_off
{
my ($time) = @_;
my (@l) = localtime($time);
my (@g) = gmtime($time);
my $off;
$off = $l[0] - $g[0]
+ ($l[1] - $g[1]) * 60
+ ($l[2] - $g[2]) * 3600;
# subscript 7 is yday.
if ($l[7] == $g[7]) {
# done
} elsif ($l[7] == $g[7] + 1) {
$off += 86400;
} elsif ($l[7] == $g[7] - 1) {
$off -= 86400;
} elsif ($l[7] < $g[7]) {
# crossed over a year boundry!
# localtime is beginning of year, gmt is end
# therefore local is ahead
$off += 86400;
} else {
$off -= 86400;
}
return $off;
}
# constants
CONFIG: {
use vars qw(%dstZone %zoneOff %dstZoneOff %Zone);
my @dstZone = (
# "ndt" => -2*3600-1800, # Newfoundland Daylight
"brst" => -2*3600, # Brazil Summer Time (East Daylight)
"adt" => -3*3600, # Atlantic Daylight
"edt" => -4*3600, # Eastern Daylight
"cdt" => -5*3600, # Central Daylight
"mdt" => -6*3600, # Mountain Daylight
"pdt" => -7*3600, # Pacific Daylight
"akdt" => -8*3600, # Alaska Daylight
"ydt" => -8*3600, # Yukon Daylight
"hdt" => -9*3600, # Hawaii Daylight
"bst" => +1*3600, # British Summer
"mest" => +2*3600, # Middle European Summer
"metdst" => +2*3600, # Middle European DST
"sst" => +2*3600, # Swedish Summer
"fst" => +2*3600, # French Summer
"cest" => +2*3600, # Central European Daylight
"eest" => +3*3600, # Eastern European Summer
"msd" => +4*3600, # Moscow Daylight
"wadt" => +8*3600, # West Australian Daylight
"kdt" => +10*3600, # Korean Daylight
# "cadt" => +10*3600+1800, # Central Australian Daylight
"aedt" => +11*3600, # Eastern Australian Daylight
"eadt" => +11*3600, # Eastern Australian Daylight
"nzd" => +13*3600, # New Zealand Daylight
"nzdt" => +13*3600, # New Zealand Daylight
);
my @Zone = (
"gmt" => 0, # Greenwich Mean
"ut" => 0, # Universal (Coordinated)
"utc" => 0,
"wet" => 0, # Western European
"wat" => -1*3600, # West Africa
"at" => -2*3600, # Azores
"fnt" => -2*3600, # Brazil Time (Extreme East - Fernando Noronha)
"brt" => -3*3600, # Brazil Time (East Standard - Brasilia)
# For completeness. BST is also British Summer, and GST is also Guam Standard.
# "bst" => -3*3600, # Brazil Standard
# "gst" => -3*3600, # Greenland Standard
# "nft" => -3*3600-1800,# Newfoundland
# "nst" => -3*3600-1800,# Newfoundland Standard
"mnt" => -4*3600, # Brazil Time (West Standard - Manaus)
"ewt" => -4*3600, # U.S. Eastern War Time
"ast" => -4*3600, # Atlantic Standard
"est" => -5*3600, # Eastern Standard
"act" => -5*3600, # Brazil Time (Extreme West - Acre)
"cst" => -6*3600, # Central Standard
"mst" => -7*3600, # Mountain Standard
"pst" => -8*3600, # Pacific Standard
"akst" => -9*3600, # Alaska Standard
"yst" => -9*3600, # Yukon Standard
"hst" => -10*3600, # Hawaii Standard
"cat" => -10*3600, # Central Alaska
"ahst" => -10*3600, # Alaska-Hawaii Standard
"nt" => -11*3600, # Nome
"idlw" => -12*3600, # International Date Line West
"cet" => +1*3600, # Central European
"mez" => +1*3600, # Central European (German)
"ect" => +1*3600, # Central European (French)
"met" => +1*3600, # Middle European
"mewt" => +1*3600, # Middle European Winter
"swt" => +1*3600, # Swedish Winter
"set" => +1*3600, # Seychelles
"fwt" => +1*3600, # French Winter
"eet" => +2*3600, # Eastern Europe, USSR Zone 1
"ukr" => +2*3600, # Ukraine
"bt" => +3*3600, # Baghdad, USSR Zone 2
"msk" => +3*3600, # Moscow
# "it" => +3*3600+1800,# Iran
"zp4" => +4*3600, # USSR Zone 3
"zp5" => +5*3600, # USSR Zone 4
# "ist" => +5*3600+1800,# Indian Standard
"zp6" => +6*3600, # USSR Zone 5
# For completeness. NST is also Newfoundland Stanard, and SST is also Swedish Summer.
# "nst" => +6*3600+1800,# North Sumatra
# "sst" => +7*3600, # South Sumatra, USSR Zone 6
# "jt" => +7*3600+1800,# Java (3pm in Cronusland!)
"wst" => +8*3600, # West Australian Standard
"hkt" => +8*3600, # Hong Kong
"cct" => +8*3600, # China Coast, USSR Zone 7
"jst" => +9*3600, # Japan Standard, USSR Zone 8
"kst" => +9*3600, # Korean Standard
# "cast" => +9*3600+1800,# Central Australian Standard
"aest" => +10*3600, # Eastern Australian Standard
"east" => +10*3600, # Eastern Australian Standard
"gst" => +10*3600, # Guam Standard, USSR Zone 9
"nzt" => +12*3600, # New Zealand
"nzst" => +12*3600, # New Zealand Standard
"idle" => +12*3600, # International Date Line East
);
%Zone = @Zone;
%dstZone = @dstZone;
%zoneOff = reverse(@Zone);
%dstZoneOff = reverse(@dstZone);
}
sub tz_offset (;$$)
{
my ($zone, $time) = @_;
return &tz_local_offset($time) unless($zone);
$time = time() unless $time;
my(@l) = localtime($time);
my $dst = $l[8];
$zone = lc $zone;
if($zone =~ /^(([\-\+])\d\d?)(\d\d)$/) {
my $v = $2 . $3;
return $1 * 3600 + $v * 60;
} elsif (exists $dstZone{$zone} && ($dst || !exists $Zone{$zone})) {
return $dstZone{$zone};
} elsif(exists $Zone{$zone}) {
return $Zone{$zone};
}
undef;
}
sub tz_name (;$$)
{
my ($off, $dst) = @_;
$off = tz_offset()
unless(defined $off);
$dst = (localtime(time))[8]
unless(defined $dst);
if (exists $dstZoneOff{$off} && ($dst || !exists $zoneOff{$off})) {
return $dstZoneOff{$off};
} elsif (exists $zoneOff{$off}) {
return $zoneOff{$off};
}
sprintf("%+05d", int($off / 60) * 100 + $off % 60);
}
1;