| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 2 | ## Lightweight DateTime Alternative - ~/lib/DateTime/Lite/Infinite.pm | ||||||||||||||||||||||||||||
| 3 | ## Version v0.1.0 | ||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2026 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||
| 6 | ## Created 2026/04/03 | ||||||||||||||||||||||||||||
| 7 | ## Modified 2026/04/10 | ||||||||||||||||||||||||||||
| 8 | ## All rights reserved | ||||||||||||||||||||||||||||
| 9 | ## | ||||||||||||||||||||||||||||
| 10 | ## | ||||||||||||||||||||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 14 | # Provides DateTime::Lite::Infinite (base), DateTime::Lite::Infinite::Future, | ||||||||||||||||||||||||||||
| 15 | # and DateTime::Lite::Infinite::Past. | ||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||
| 17 | # These objects are singletons. All "get" accessors return the system's | ||||||||||||||||||||||||||||
| 18 | # representation of positive or negative infinity. The mutating methods | ||||||||||||||||||||||||||||
| 19 | # set(), set_time_zone(), and truncate() are no-ops that return $self. | ||||||||||||||||||||||||||||
| 20 | # | ||||||||||||||||||||||||||||
| 21 | # NOTE: This file intentionally defines multiple packages. | ||||||||||||||||||||||||||||
| 22 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 23 | package DateTime::Lite::Infinite; | ||||||||||||||||||||||||||||
| 24 | BEGIN | ||||||||||||||||||||||||||||
| 25 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=14.6
| |||||||||||||||||||||||||||||
| 26 | 2 | ▶ | use v5.10.1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 2 | ▶ | if( $] < 5.013 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | { | ||||||||||||||||||||||||||||
| 31 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | unless( defined( &warnings::register_categories ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | { | ||||||||||||||||||||||||||||
| 34 | *warnings::_mkMask = sub | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 36 | 0 | my $bit = shift( @_ ); | |||||||||||||||||||||||||||
| 37 | 0 | my $mask = ""; | |||||||||||||||||||||||||||
| 38 | 0 | vec( $mask, $bit, 1 ) = 1; | |||||||||||||||||||||||||||
| 39 | 0 | return( $mask ); | |||||||||||||||||||||||||||
| 40 | 0 | }; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | *warnings::register_categories = sub | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 44 | 0 | my @names = @_; | |||||||||||||||||||||||||||
| 45 | 0 | foreach my $name ( @names ) | |||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if( !defined( $warnings::Bits{ $name } ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||
| 49 | 0 | $warnings::Offsets{ $name } = $warnings::LAST_BIT; | |||||||||||||||||||||||||||
| 50 | 0 | $warnings::Bits{ $name } = warnings::_mkMask( $warnings::LAST_BIT++ ); | |||||||||||||||||||||||||||
| 51 | 0 | $warnings::DeadBits{ $name } = warnings::_mkMask( $warnings::LAST_BIT++ ); | |||||||||||||||||||||||||||
| 52 | 0 | ▶ | if( length( $warnings::Bits{ $name } ) > length( $warnings::Bits{all} ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||
| 54 | 0 | $warnings::Bits{all} .= "\x55"; | |||||||||||||||||||||||||||
| 55 | 0 | $warnings::DeadBits{all} .= "\xaa"; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 0 | }; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | 2 | warnings::register_categories( 'DateTime::Lite' ); | |||||||||||||||||||||||||||
| 63 | 2 | ▶ | use parent qw( DateTime::Lite ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 64 | 2 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 65 | 2 | our $VERSION = 'v0.1.0'; | |||||||||||||||||||||||||||
| 66 | }; | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | # Mutating methods are no-ops on infinite objects | ||||||||||||||||||||||||||||
| 69 | 2 | foreach my $m ( qw( set set_time_zone truncate ) ) | |||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||
| 71 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 72 | 2 | ▶ | *{ 'DateTime::Lite::Infinite::' . $m } = sub{ return( $_[0] ) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 2 | ▶ | sub is_finite { 0 } | ||||||||||||||||||||||||||
|
Subroutine
is_finite: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 76 | 17 | ▶ | sub is_infinite { 1 } | ||||||||||||||||||||||||||
|
Subroutine
is_infinite: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | # Override the XS/PP calendar decomposition to just propagate the | ||||||||||||||||||||||||||||
| 79 | # infinity value through without any arithmetic | ||||||||||||||||||||||||||||
| 80 | sub _rd2ymd | ||||||||||||||||||||||||||||
| 81 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_rd2ymd: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 82 | 2 | ▶ | return( $_[2] ? ( $_[1] ) x 7 : ( $_[1] ) x 3 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | sub _seconds_as_components | ||||||||||||||||||||||||||||
| 86 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_seconds_as_components: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 87 | 2 | return( ( $_[1] ) x 3 ); | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | # NOTE: Formatting - all return the infinity string | ||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub datetime { return( $_[0]->_infinity_string ) } | ||||||||||||||||||||||||||
|
Subroutine
datetime: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub dmy { return( $_[0]->iso8601 ) } | ||||||||||||||||||||||||||
|
Subroutine
dmy: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub hms { return( $_[0]->iso8601 ) } | ||||||||||||||||||||||||||
|
Subroutine
hms: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub hour_12 { return( $_[0]->_infinity_string ) } | ||||||||||||||||||||||||||
|
Subroutine
hour_12: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub hour_12_0 { return( $_[0]->_infinity_string ) } | ||||||||||||||||||||||||||
|
Subroutine
hour_12_0: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub mdy { return( $_[0]->iso8601 ) } | ||||||||||||||||||||||||||
|
Subroutine
mdy: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub stringify { return( $_[0]->_infinity_string ) } | ||||||||||||||||||||||||||
|
Subroutine
stringify: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub ymd { return( $_[0]->iso8601 ) } | ||||||||||||||||||||||||||
|
Subroutine
ymd: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | sub _infinity_string | ||||||||||||||||||||||||||||
| 101 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_infinity_string: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | return( $_[0]->{utc_rd_days} == DateTime::Lite::INFINITY() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | ? DateTime::Lite::INFINITY() . q{} | ||||||||||||||||||||||||||||
| 104 | : DateTime::Lite::NEG_INFINITY() . q{} ); | ||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub _week_values { return( [ $_[0]->{utc_rd_days}, $_[0]->{utc_rd_days} ] ) } | ||||||||||||||||||||||||||
|
Subroutine
_week_values: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | # Infinite objects are not serialisable in a meaningful way | ||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub STORABLE_freeze { return } | ||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | sub STORABLE_thaw { return } | ||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 2 | 1; | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | # NOTE: DateTime::Lite::Infinite::Future class | ||||||||||||||||||||||||||||
| 116 | package DateTime::Lite::Infinite::Future; | ||||||||||||||||||||||||||||
| 117 | BEGIN | ||||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||
| 119 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 120 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 121 | 2 | ▶ | use parent qw( DateTime::Lite::Infinite ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 122 | }; | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | { | ||||||||||||||||||||||||||||
| 126 | 2 | my $Pos; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | sub new | ||||||||||||||||||||||||||||
| 129 | 9 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 130 | 9 | ▶ | return( $Pos ) if( defined( $Pos ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 1 | require DateTime::Lite::TimeZone; | |||||||||||||||||||||||||||
| 133 | 1 | $Pos = bless( | |||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||
| 135 | utc_rd_days => DateTime::Lite::INFINITY(), | ||||||||||||||||||||||||||||
| 136 | utc_rd_secs => DateTime::Lite::INFINITY(), | ||||||||||||||||||||||||||||
| 137 | local_rd_days => DateTime::Lite::INFINITY(), | ||||||||||||||||||||||||||||
| 138 | local_rd_secs => DateTime::Lite::INFINITY(), | ||||||||||||||||||||||||||||
| 139 | rd_nanosecs => DateTime::Lite::INFINITY(), | ||||||||||||||||||||||||||||
| 140 | offset_modifier => 0, | ||||||||||||||||||||||||||||
| 141 | tz => DateTime::Lite::TimeZone->new( name => 'floating' ), | ||||||||||||||||||||||||||||
| 142 | locale => DateTime::Lite::_FakeLocale->instance, | ||||||||||||||||||||||||||||
| 143 | }, | ||||||||||||||||||||||||||||
| 144 | __PACKAGE__ ); | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | # _calc_utc_rd and _calc_local_rd are no-ops for infinities because | ||||||||||||||||||||||||||||
| 147 | # _normalize_tai_seconds short-circuits on non-finite values (XS | ||||||||||||||||||||||||||||
| 148 | # checks dtl_isfinite; PP version checks the range and does nothing | ||||||||||||||||||||||||||||
| 149 | # for infinities). However we still call them so the local_c hash | ||||||||||||||||||||||||||||
| 150 | # is populated in a consistent way. | ||||||||||||||||||||||||||||
| 151 | 1 | eval { $Pos->_calc_utc_rd }; | |||||||||||||||||||||||||||
| 152 | 1 | eval { $Pos->_calc_local_rd }; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 1 | return( $Pos ); | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 2 | 1; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | # NOTE: DateTime::Lite::Infinite::Past class | ||||||||||||||||||||||||||||
| 161 | package DateTime::Lite::Infinite::Past; | ||||||||||||||||||||||||||||
| 162 | BEGIN | ||||||||||||||||||||||||||||
| 163 | { | ||||||||||||||||||||||||||||
| 164 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 165 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 166 | 2 | ▶ | use parent qw( DateTime::Lite::Infinite ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 167 | }; | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||
| 170 | 2 | my $Neg; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | sub new | ||||||||||||||||||||||||||||
| 173 | 7 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 174 | 7 | ▶ | return( $Neg ) if( defined( $Neg ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 1 | require DateTime::Lite::TimeZone; | |||||||||||||||||||||||||||
| 177 | 1 | $Neg = bless( | |||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||
| 179 | utc_rd_days => DateTime::Lite::NEG_INFINITY(), | ||||||||||||||||||||||||||||
| 180 | utc_rd_secs => DateTime::Lite::NEG_INFINITY(), | ||||||||||||||||||||||||||||
| 181 | local_rd_days => DateTime::Lite::NEG_INFINITY(), | ||||||||||||||||||||||||||||
| 182 | local_rd_secs => DateTime::Lite::NEG_INFINITY(), | ||||||||||||||||||||||||||||
| 183 | rd_nanosecs => DateTime::Lite::NEG_INFINITY(), | ||||||||||||||||||||||||||||
| 184 | offset_modifier => 0, | ||||||||||||||||||||||||||||
| 185 | tz => DateTime::Lite::TimeZone->new( name => 'floating' ), | ||||||||||||||||||||||||||||
| 186 | locale => DateTime::Lite::_FakeLocale->instance, | ||||||||||||||||||||||||||||
| 187 | }, | ||||||||||||||||||||||||||||
| 188 | __PACKAGE__ ); | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 1 | eval { $Neg->_calc_utc_rd }; | |||||||||||||||||||||||||||
| 191 | 1 | eval { $Neg->_calc_local_rd }; | |||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 1 | return( $Neg ); | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 2 | 1; | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | # A minimal locale stub used only by Infinite objects. | ||||||||||||||||||||||||||||
| 200 | # It proxies format-related calls to a real en-US locale object (via | ||||||||||||||||||||||||||||
| 201 | # DateTime::Locale::FromCLDR), and returns sensible no-op values for everything else | ||||||||||||||||||||||||||||
| 202 | # that DateTime::Lite might call. | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | # NOTE: DateTime::Lite::_FakeLocale class | ||||||||||||||||||||||||||||
| 205 | package DateTime::Lite::_FakeLocale; | ||||||||||||||||||||||||||||
| 206 | BEGIN | ||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||
| 208 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 209 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 210 | }; | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 2 | my $Instance; | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | sub instance | ||||||||||||||||||||||||||||
| 215 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
instance: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 216 | 2 | ▶ | return( $Instance ) if( defined( $Instance ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 1 | require DateTime::Locale::FromCLDR; | |||||||||||||||||||||||||||
| 219 | 1 | $Instance = bless( | |||||||||||||||||||||||||||
| 220 | { | ||||||||||||||||||||||||||||
| 221 | _real => DateTime::Locale::FromCLDR->new( 'en-US' ), | ||||||||||||||||||||||||||||
| 222 | }, | ||||||||||||||||||||||||||||
| 223 | __PACKAGE__ ); | ||||||||||||||||||||||||||||
| 224 | 1 | return( $Instance ); | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub id { return( 'infinite' ) } | ||||||||||||||||||||||||||
|
Subroutine
id: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 228 | 0 | ▶ | sub language_id { return( 'infinite' ) } | ||||||||||||||||||||||||||
|
Subroutine
language_id: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub name { return( 'Fake locale for Infinite DateTime::Lite objects' ) } | ||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 230 | 0 | ▶ | sub language { return( 'Fake locale for Infinite DateTime::Lite objects' ) } | ||||||||||||||||||||||||||
|
Subroutine
language: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | # These return undef - they are present so DateTime::Lite's format_cldr and | ||||||||||||||||||||||||||||
| 233 | # strftime do not die on missing methods. | ||||||||||||||||||||||||||||
| 234 | 2 | foreach my $m ( qw( | |||||||||||||||||||||||||||
| 235 | script_id territory_id variant_id | ||||||||||||||||||||||||||||
| 236 | script territory variant | ||||||||||||||||||||||||||||
| 237 | native_name native_language native_script native_territory native_variant | ||||||||||||||||||||||||||||
| 238 | ) ) | ||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||
| 240 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | *{ __PACKAGE__ . '::' . $m } = sub{ return( undef ) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub first_day_of_week { return(1) } | ||||||||||||||||||||||||||
|
Subroutine
first_day_of_week: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub prefers_24_hour_time { return(0) } | ||||||||||||||||||||||||||
|
Subroutine
prefers_24_hour_time: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | # Proxy format-related calls (day/month/quarter names, era strings, etc.) | ||||||||||||||||||||||||||||
| 248 | # to the real locale object. Everything else that returns a list, such as | ||||||||||||||||||||||||||||
| 249 | # month_format_wide, day_format_wide, returns an empty arrayref. | ||||||||||||||||||||||||||||
| 250 | 2 | our $AUTOLOAD; | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | sub AUTOLOAD | ||||||||||||||||||||||||||||
| 253 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 254 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||
| 255 | 0 | my( $meth ) = $AUTOLOAD =~ /::(\w+)$/; | |||||||||||||||||||||||||||
| 256 | 0 | ▶ | return if( $meth eq 'DESTROY' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | # Proxy date/time formatting methods to the real locale | ||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if( $meth =~ /format|era|am_pm|period/i | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$meth =~ /format|era|am_pm|period/i and not $meth =~ /^(?:day|month|quarter)_(?:format|stand)/
MC/DC0%0/2
$meth =~ /format|era|am_pm|period/i and not $meth =~ /^(?:day|month|quarter)_(?:format|stand)/
$meth =~ /format|era|am_pm|period/i
not $meth =~ /^(?:day|month|quarter)_(?:format|stand)/
Truth table0%0/3
A and not(B)
A= $meth =~ /format|era|am_pm|period/iB= not $meth =~ /^(?:day|month|quarter)_(?:format|stand)/
| |||||||||||||||||||||||||||||
| 260 | && $meth !~ /^(?:day|month|quarter)_(?:format|stand)/ ) | ||||||||||||||||||||||||||||
| 261 | { | ||||||||||||||||||||||||||||
| 262 | 0 | return( $self->{_real}->$meth( @_ ) ); | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | # All array-returning methods (month names, day names, etc.) return [] | ||||||||||||||||||||||||||||
| 266 | 0 | return( [] ); | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 2 | 1; | |||||||||||||||||||||||||||
| 270 | # NOTE: POD | ||||||||||||||||||||||||||||
| 271 | __END__ | ||||||||||||||||||||||||||||