← Index
NYTProf Performance Profile   « line view »
For -e
  Run on Thu Jun 30 16:34:56 2016
Reported on Thu Jun 30 16:35:08 2016

Filename/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm
StatementsExecuted 1345276 statements in 2.21s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1300031362ms908msDateTime::::_new DateTime::_new
1000021302ms1.57sDateTime::::_new_from_self DateTime::_new_from_self
400022114ms593msDateTime::::truncate DateTime::truncate
130001194.5ms144msDateTime::::_handle_offset_modifier DateTime::_handle_offset_modifier
130021194.4ms109msDateTime::::_calc_local_components DateTime::_calc_local_components
60002183.3ms1.37sDateTime::::set DateTime::set
130023272.9ms186msDateTime::::_calc_local_rd DateTime::_calc_local_rd
30001171.7ms414msDateTime::::from_epoch DateTime::from_epoch
130023267.6ms82.4msDateTime::::_calc_utc_rd DateTime::_calc_utc_rd
60001165.6ms940msDateTime::::new DateTime::new
510008138.9ms38.9msDateTime::::CORE:match DateTime::CORE:match (opcode)
130001137.4ms43.1msDateTime::::_offset_for_local_datetime DateTime::_offset_for_local_datetime
90002132.2ms39.9msDateTime::::__ANON__[:127] DateTime::__ANON__[:127]
90002130.6ms38.3msDateTime::::__ANON__[:135] DateTime::__ANON__[:135]
130001127.4ms30.3msDateTime::::_set_locale DateTime::_set_locale
60001122.6ms26.5msDateTime::::__ANON__[:159] DateTime::__ANON__[:159]
60001120.9ms24.7msDateTime::::__ANON__[:166] DateTime::__ANON__[:166]
60001120.5ms25.1msDateTime::::__ANON__[:143] DateTime::__ANON__[:143]
60001119.8ms25.3msDateTime::::__ANON__[:119] DateTime::__ANON__[:119]
30001118.2ms434msDateTime::::now DateTime::now
160002118.0ms18.0msDateTime::::_maybe_future_dst_warning DateTime::_maybe_future_dst_warning
170003116.8ms16.8msDateTime::::year DateTime::year
30001116.2ms890msDateTime::::today DateTime::today
60001114.2ms18.4msDateTime::::__ANON__[:151] DateTime::__ANON__[:151]
140002110.8ms10.8msDateTime::::month DateTime::month
140002110.3ms10.3msDateTime::::day_of_month DateTime::day_of_month
13000119.87ms9.87msDateTime::::_normalize_nanoseconds DateTime::_normalize_nanoseconds
3000119.73ms691msDateTime::::set_month DateTime::set_month
13002118.66ms8.66msDateTime::::_normalize_tai_seconds DateTime::_normalize_tai_seconds (xsub)
13000118.17ms8.17msDateTime::::_rd2ymd DateTime::_rd2ymd (xsub)
13000118.09ms8.09msDateTime::::_ymd2rd DateTime::_ymd2rd (xsub)
10000117.03ms7.03msDateTime::::time_zone DateTime::time_zone
3000116.93ms698msDateTime::::set_day DateTime::set_day
10000116.81ms6.81msDateTime::::minute DateTime::minute
10000116.80ms6.80msDateTime::::hour DateTime::hour
10000116.79ms6.79msDateTime::::locale DateTime::locale
10000116.67ms6.67msDateTime::::nanosecond DateTime::nanosecond
13000116.58ms6.58msDateTime::::_seconds_as_components DateTime::_seconds_as_components (xsub)
10000116.25ms6.25msDateTime::::second DateTime::second
10000116.21ms6.21msDateTime::::formatter DateTime::formatter
13000115.64ms5.64msDateTime::::_time_as_seconds DateTime::_time_as_seconds (xsub)
1113.41ms6.73msDateTime::::BEGIN@18 DateTime::BEGIN@18
3001212.93ms2.95msDateTime::::DefaultLocale DateTime::DefaultLocale
1112.80ms9.73msDateTime::::BEGIN@15 DateTime::BEGIN@15
1111.92ms13.2msDateTime::::BEGIN@12 DateTime::BEGIN@12
3000111.84ms1.84msDateTime::::_core_time DateTime::_core_time
1111.69ms19.2msDateTime::::BEGIN@14 DateTime::BEGIN@14
111363µs366µsDateTime::::BEGIN@763 DateTime::BEGIN@763
603147µs47µsDateTime::::CORE:qr DateTime::CORE:qr (opcode)
11126µs26µsDateTime::::BEGIN@3 DateTime::BEGIN@3
11124µs24µsDateTime::::CORE:regcomp DateTime::CORE:regcomp (opcode)
11112µs63µsDateTime::::BEGIN@16 DateTime::BEGIN@16
11111µs211µsDateTime::::try {...} DateTime::try {...}
11110µs12µsDateTime::::BEGIN@1925 DateTime::BEGIN@1925
1119µs12µsDateTime::::BEGIN@5 DateTime::BEGIN@5
1119µs60µsDateTime::::BEGIN@57 DateTime::BEGIN@57
1118µs52µsDateTime::::BEGIN@11 DateTime::BEGIN@11
1118µs89µsDateTime::::BEGIN@7 DateTime::BEGIN@7
1118µs34µsDateTime::::BEGIN@19 DateTime::BEGIN@19
1118µs13µsDateTime::::BEGIN@6 DateTime::BEGIN@6
1118µs40µsDateTime::::BEGIN@75 DateTime::BEGIN@75
1117µs47µsDateTime::::BEGIN@74 DateTime::BEGIN@74
1117µs34µsDateTime::::BEGIN@76 DateTime::BEGIN@76
1117µs48µsDateTime::::BEGIN@72 DateTime::BEGIN@72
1116µs34µsDateTime::::BEGIN@78 DateTime::BEGIN@78
1116µs32µsDateTime::::BEGIN@80 DateTime::BEGIN@80
1115µs5µsDateTime::::BEGIN@13 DateTime::BEGIN@13
1115µs5µsDateTime::::BEGIN@84 DateTime::BEGIN@84
0000s0sDateTime::::STORABLE_freeze DateTime::STORABLE_freeze
0000s0sDateTime::::STORABLE_thaw DateTime::STORABLE_thaw
0000s0sDateTime::_Thawed::::time_zoneDateTime::_Thawed::time_zone
0000s0sDateTime::_Thawed::::utc_rd_valuesDateTime::_Thawed::utc_rd_values
0000s0sDateTime::::__ANON__[:1034] DateTime::__ANON__[:1034]
0000s0sDateTime::::__ANON__[:1035] DateTime::__ANON__[:1035]
0000s0sDateTime::::__ANON__[:1036] DateTime::__ANON__[:1036]
0000s0sDateTime::::__ANON__[:1037] DateTime::__ANON__[:1037]
0000s0sDateTime::::__ANON__[:1040] DateTime::__ANON__[:1040]
0000s0sDateTime::::__ANON__[:1041] DateTime::__ANON__[:1041]
0000s0sDateTime::::__ANON__[:1042] DateTime::__ANON__[:1042]
0000s0sDateTime::::__ANON__[:1043] DateTime::__ANON__[:1043]
0000s0sDateTime::::__ANON__[:1044] DateTime::__ANON__[:1044]
0000s0sDateTime::::__ANON__[:1045] DateTime::__ANON__[:1045]
0000s0sDateTime::::__ANON__[:1046] DateTime::__ANON__[:1046]
0000s0sDateTime::::__ANON__[:1047] DateTime::__ANON__[:1047]
0000s0sDateTime::::__ANON__[:1048] DateTime::__ANON__[:1048]
0000s0sDateTime::::__ANON__[:1049] DateTime::__ANON__[:1049]
0000s0sDateTime::::__ANON__[:1050] DateTime::__ANON__[:1050]
0000s0sDateTime::::__ANON__[:1051] DateTime::__ANON__[:1051]
0000s0sDateTime::::__ANON__[:1052] DateTime::__ANON__[:1052]
0000s0sDateTime::::__ANON__[:1053] DateTime::__ANON__[:1053]
0000s0sDateTime::::__ANON__[:1054] DateTime::__ANON__[:1054]
0000s0sDateTime::::__ANON__[:1055] DateTime::__ANON__[:1055]
0000s0sDateTime::::__ANON__[:1057] DateTime::__ANON__[:1057]
0000s0sDateTime::::__ANON__[:1058] DateTime::__ANON__[:1058]
0000s0sDateTime::::__ANON__[:1059] DateTime::__ANON__[:1059]
0000s0sDateTime::::__ANON__[:1060] DateTime::__ANON__[:1060]
0000s0sDateTime::::__ANON__[:1061] DateTime::__ANON__[:1061]
0000s0sDateTime::::__ANON__[:1062] DateTime::__ANON__[:1062]
0000s0sDateTime::::__ANON__[:1063] DateTime::__ANON__[:1063]
0000s0sDateTime::::__ANON__[:1064] DateTime::__ANON__[:1064]
0000s0sDateTime::::__ANON__[:1065] DateTime::__ANON__[:1065]
0000s0sDateTime::::__ANON__[:1069] DateTime::__ANON__[:1069]
0000s0sDateTime::::__ANON__[:1070] DateTime::__ANON__[:1070]
0000s0sDateTime::::__ANON__[:1074] DateTime::__ANON__[:1074]
0000s0sDateTime::::__ANON__[:1078] DateTime::__ANON__[:1078]
0000s0sDateTime::::__ANON__[:1081] DateTime::__ANON__[:1081]
0000s0sDateTime::::__ANON__[:1084] DateTime::__ANON__[:1084]
0000s0sDateTime::::__ANON__[:1085] DateTime::__ANON__[:1085]
0000s0sDateTime::::__ANON__[:1086] DateTime::__ANON__[:1086]
0000s0sDateTime::::__ANON__[:1087] DateTime::__ANON__[:1087]
0000s0sDateTime::::__ANON__[:1088] DateTime::__ANON__[:1088]
0000s0sDateTime::::__ANON__[:1089] DateTime::__ANON__[:1089]
0000s0sDateTime::::__ANON__[:1138] DateTime::__ANON__[:1138]
0000s0sDateTime::::__ANON__[:1143] DateTime::__ANON__[:1143]
0000s0sDateTime::::__ANON__[:1151] DateTime::__ANON__[:1151]
0000s0sDateTime::::__ANON__[:1152] DateTime::__ANON__[:1152]
0000s0sDateTime::::__ANON__[:1153] DateTime::__ANON__[:1153]
0000s0sDateTime::::__ANON__[:1155] DateTime::__ANON__[:1155]
0000s0sDateTime::::__ANON__[:1160] DateTime::__ANON__[:1160]
0000s0sDateTime::::__ANON__[:1165] DateTime::__ANON__[:1165]
0000s0sDateTime::::__ANON__[:1169] DateTime::__ANON__[:1169]
0000s0sDateTime::::__ANON__[:1171] DateTime::__ANON__[:1171]
0000s0sDateTime::::__ANON__[:1174] DateTime::__ANON__[:1174]
0000s0sDateTime::::__ANON__[:1178] DateTime::__ANON__[:1178]
0000s0sDateTime::::__ANON__[:1182] DateTime::__ANON__[:1182]
0000s0sDateTime::::__ANON__[:1185] DateTime::__ANON__[:1185]
0000s0sDateTime::::__ANON__[:1189] DateTime::__ANON__[:1189]
0000s0sDateTime::::__ANON__[:1190] DateTime::__ANON__[:1190]
0000s0sDateTime::::__ANON__[:1193] DateTime::__ANON__[:1193]
0000s0sDateTime::::__ANON__[:1197] DateTime::__ANON__[:1197]
0000s0sDateTime::::__ANON__[:1199] DateTime::__ANON__[:1199]
0000s0sDateTime::::__ANON__[:1202] DateTime::__ANON__[:1202]
0000s0sDateTime::::__ANON__[:1206] DateTime::__ANON__[:1206]
0000s0sDateTime::::__ANON__[:1212] DateTime::__ANON__[:1212]
0000s0sDateTime::::__ANON__[:1217] DateTime::__ANON__[:1217]
0000s0sDateTime::::__ANON__[:1222] DateTime::__ANON__[:1222]
0000s0sDateTime::::__ANON__[:1225] DateTime::__ANON__[:1225]
0000s0sDateTime::::__ANON__[:1229] DateTime::__ANON__[:1229]
0000s0sDateTime::::__ANON__[:1231] DateTime::__ANON__[:1231]
0000s0sDateTime::::__ANON__[:1236] DateTime::__ANON__[:1236]
0000s0sDateTime::::__ANON__[:1237] DateTime::__ANON__[:1237]
0000s0sDateTime::::__ANON__[:1239] DateTime::__ANON__[:1239]
0000s0sDateTime::::__ANON__[:1241] DateTime::__ANON__[:1241]
0000s0sDateTime::::__ANON__[:1248] DateTime::__ANON__[:1248]
0000s0sDateTime::::__ANON__[:1251] DateTime::__ANON__[:1251]
0000s0sDateTime::::__ANON__[:1254] DateTime::__ANON__[:1254]
0000s0sDateTime::::__ANON__[:1267] DateTime::__ANON__[:1267]
0000s0sDateTime::::__ANON__[:1269] DateTime::__ANON__[:1269]
0000s0sDateTime::::__ANON__[:1271] DateTime::__ANON__[:1271]
0000s0sDateTime::::__ANON__[:1272] DateTime::__ANON__[:1272]
0000s0sDateTime::::__ANON__[:1280] DateTime::__ANON__[:1280]
0000s0sDateTime::::__ANON__[:1284] DateTime::__ANON__[:1284]
0000s0sDateTime::::__ANON__[:1286] DateTime::__ANON__[:1286]
0000s0sDateTime::::__ANON__[:1287] DateTime::__ANON__[:1287]
0000s0sDateTime::::__ANON__[:1288] DateTime::__ANON__[:1288]
0000s0sDateTime::::__ANON__[:1289] DateTime::__ANON__[:1289]
0000s0sDateTime::::__ANON__[:1290] DateTime::__ANON__[:1290]
0000s0sDateTime::::__ANON__[:1463] DateTime::__ANON__[:1463]
0000s0sDateTime::::__ANON__[:1474] DateTime::__ANON__[:1474]
0000s0sDateTime::::__ANON__[:182] DateTime::__ANON__[:182]
0000s0sDateTime::::__ANON__[:2029] DateTime::__ANON__[:2029]
0000s0sDateTime::::__ANON__[:2033] DateTime::__ANON__[:2033]
0000s0sDateTime::::__ANON__[:2083] DateTime::__ANON__[:2083]
0000s0sDateTime::::__ANON__[:2086] DateTime::__ANON__[:2086]
0000s0sDateTime::::__ANON__[:36] DateTime::__ANON__[:36]
0000s0sDateTime::::__ANON__[:39] DateTime::__ANON__[:39]
0000s0sDateTime::::__ANON__[:679] DateTime::__ANON__[:679]
0000s0sDateTime::::__ANON__[:828] DateTime::__ANON__[:828]
0000s0sDateTime::::__ANON__[:914] DateTime::__ANON__[:914]
0000s0sDateTime::::__ANON__[:917] DateTime::__ANON__[:917]
0000s0sDateTime::::_add_overload DateTime::_add_overload
0000s0sDateTime::::_adjust_for_positive_difference DateTime::_adjust_for_positive_difference
0000s0sDateTime::::_cldr_pattern DateTime::_cldr_pattern
0000s0sDateTime::::_compare DateTime::_compare
0000s0sDateTime::::_compare_overload DateTime::_compare_overload
0000s0sDateTime::::_default_time_zone DateTime::_default_time_zone
0000s0sDateTime::::_era_index DateTime::_era_index
0000s0sDateTime::::_format_nanosecs DateTime::_format_nanosecs
0000s0sDateTime::::_month_length DateTime::_month_length
0000s0sDateTime::::_normalize_seconds DateTime::_normalize_seconds
0000s0sDateTime::::_space_padded_string DateTime::_space_padded_string
0000s0sDateTime::::_string_compare_overload DateTime::_string_compare_overload
0000s0sDateTime::::_string_equals_overload DateTime::_string_equals_overload
0000s0sDateTime::::_string_not_equals_overload DateTime::_string_not_equals_overload
0000s0sDateTime::::_stringify DateTime::_stringify
0000s0sDateTime::::_subtract_overload DateTime::_subtract_overload
0000s0sDateTime::::_weeks_in_year DateTime::_weeks_in_year
0000s0sDateTime::::_zero_padded_number DateTime::_zero_padded_number
0000s0sDateTime::::add DateTime::add
0000s0sDateTime::::add_duration DateTime::add_duration
0000s0sDateTime::::am_or_pm DateTime::am_or_pm
0000s0sDateTime::::catch {...} DateTime::catch {...}
0000s0sDateTime::::ce_year DateTime::ce_year
0000s0sDateTime::::christian_era DateTime::christian_era
0000s0sDateTime::::clone DateTime::clone
0000s0sDateTime::::compare DateTime::compare
0000s0sDateTime::::compare_ignore_floating DateTime::compare_ignore_floating
0000s0sDateTime::::day_abbr DateTime::day_abbr
0000s0sDateTime::::day_name DateTime::day_name
0000s0sDateTime::::day_of_month_0 DateTime::day_of_month_0
0000s0sDateTime::::day_of_quarter DateTime::day_of_quarter
0000s0sDateTime::::day_of_quarter_0 DateTime::day_of_quarter_0
0000s0sDateTime::::day_of_week DateTime::day_of_week
0000s0sDateTime::::day_of_week_0 DateTime::day_of_week_0
0000s0sDateTime::::day_of_year DateTime::day_of_year
0000s0sDateTime::::day_of_year_0 DateTime::day_of_year_0
0000s0sDateTime::::delta_days DateTime::delta_days
0000s0sDateTime::::delta_md DateTime::delta_md
0000s0sDateTime::::delta_ms DateTime::delta_ms
0000s0sDateTime::::dmy DateTime::dmy
0000s0sDateTime::::epoch DateTime::epoch
0000s0sDateTime::::era_abbr DateTime::era_abbr
0000s0sDateTime::::era_name DateTime::era_name
0000s0sDateTime::::format_cldr DateTime::format_cldr
0000s0sDateTime::::fractional_second DateTime::fractional_second
0000s0sDateTime::::from_day_of_year DateTime::from_day_of_year
0000s0sDateTime::::from_object DateTime::from_object
0000s0sDateTime::::hires_epoch DateTime::hires_epoch
0000s0sDateTime::::hms DateTime::hms
0000s0sDateTime::::hour_1 DateTime::hour_1
0000s0sDateTime::::hour_12 DateTime::hour_12
0000s0sDateTime::::hour_12_0 DateTime::hour_12_0
0000s0sDateTime::::is_dst DateTime::is_dst
0000s0sDateTime::::is_finite DateTime::is_finite
0000s0sDateTime::::is_infinite DateTime::is_infinite
0000s0sDateTime::::is_leap_year DateTime::is_leap_year
0000s0sDateTime::::iso8601 DateTime::iso8601
0000s0sDateTime::::jd DateTime::jd
0000s0sDateTime::::last_day_of_month DateTime::last_day_of_month
0000s0sDateTime::::leap_seconds DateTime::leap_seconds
0000s0sDateTime::::local_day_of_week DateTime::local_day_of_week
0000s0sDateTime::::local_rd_as_seconds DateTime::local_rd_as_seconds
0000s0sDateTime::::local_rd_values DateTime::local_rd_values
0000s0sDateTime::::mdy DateTime::mdy
0000s0sDateTime::::microsecond DateTime::microsecond
0000s0sDateTime::::millisecond DateTime::millisecond
0000s0sDateTime::::mjd DateTime::mjd
0000s0sDateTime::::month_0 DateTime::month_0
0000s0sDateTime::::month_abbr DateTime::month_abbr
0000s0sDateTime::::month_name DateTime::month_name
0000s0sDateTime::::offset DateTime::offset
0000s0sDateTime::::quarter DateTime::quarter
0000s0sDateTime::::quarter_0 DateTime::quarter_0
0000s0sDateTime::::quarter_abbr DateTime::quarter_abbr
0000s0sDateTime::::quarter_name DateTime::quarter_name
0000s0sDateTime::::secular_era DateTime::secular_era
0000s0sDateTime::::set_formatter DateTime::set_formatter
0000s0sDateTime::::set_hour DateTime::set_hour
0000s0sDateTime::::set_locale DateTime::set_locale
0000s0sDateTime::::set_minute DateTime::set_minute
0000s0sDateTime::::set_nanosecond DateTime::set_nanosecond
0000s0sDateTime::::set_second DateTime::set_second
0000s0sDateTime::::set_time_zone DateTime::set_time_zone
0000s0sDateTime::::set_year DateTime::set_year
0000s0sDateTime::::strftime DateTime::strftime
0000s0sDateTime::::subtract DateTime::subtract
0000s0sDateTime::::subtract_datetime DateTime::subtract_datetime
0000s0sDateTime::::subtract_datetime_absolute DateTime::subtract_datetime_absolute
0000s0sDateTime::::subtract_duration DateTime::subtract_duration
0000s0sDateTime::::time_zone_long_name DateTime::time_zone_long_name
0000s0sDateTime::::time_zone_short_name DateTime::time_zone_short_name
0000s0sDateTime::::utc_rd_as_seconds DateTime::utc_rd_as_seconds
0000s0sDateTime::::utc_rd_values DateTime::utc_rd_values
0000s0sDateTime::::utc_year DateTime::utc_year
0000s0sDateTime::::week DateTime::week
0000s0sDateTime::::week_number DateTime::week_number
0000s0sDateTime::::week_of_month DateTime::week_of_month
0000s0sDateTime::::week_year DateTime::week_year
0000s0sDateTime::::weekday_of_month DateTime::weekday_of_month
0000s0sDateTime::::year_with_christian_era DateTime::year_with_christian_era
0000s0sDateTime::::year_with_era DateTime::year_with_era
0000s0sDateTime::::year_with_secular_era DateTime::year_with_secular_era
0000s0sDateTime::::ymd DateTime::ymd
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package DateTime;
2
3251µs126µs
# spent 26µs within DateTime::BEGIN@3 which was called: # once (26µs+0s) by DateTime::Format::Alami::parse_datetime at line 3
use 5.008001;
# spent 26µs making 1 call to DateTime::BEGIN@3
4
5224µs215µs
# spent 12µs (9+3) within DateTime::BEGIN@5 which was called: # once (9µs+3µs) by DateTime::Format::Alami::parse_datetime at line 5
use strict;
# spent 12µs making 1 call to DateTime::BEGIN@5 # spent 3µs making 1 call to strict::import
6223µs219µs
# spent 13µs (8+6) within DateTime::BEGIN@6 which was called: # once (8µs+6µs) by DateTime::Format::Alami::parse_datetime at line 6
use warnings;
# spent 13µs making 1 call to DateTime::BEGIN@6 # spent 6µs making 1 call to warnings::import
7238µs2170µs
# spent 89µs (8+81) within DateTime::BEGIN@7 which was called: # once (8µs+81µs) by DateTime::Format::Alami::parse_datetime at line 7
use warnings::register;
# spent 89µs making 1 call to DateTime::BEGIN@7 # spent 81µs making 1 call to warnings::register::import
8
91500nsour $VERSION = '1.27';
10
11225µs295µs
# spent 52µs (8+44) within DateTime::BEGIN@11 which was called: # once (8µs+44µs) by DateTime::Format::Alami::parse_datetime at line 11
use Carp;
# spent 52µs making 1 call to DateTime::BEGIN@11 # spent 44µs making 1 call to Exporter::import
122318µs113.2ms
# spent 13.2ms (1.92+11.2) within DateTime::BEGIN@12 which was called: # once (1.92ms+11.2ms) by DateTime::Format::Alami::parse_datetime at line 12
use DateTime::Duration;
# spent 13.2ms making 1 call to DateTime::BEGIN@12
13225µs15µs
# spent 5µs within DateTime::BEGIN@13 which was called: # once (5µs+0s) by DateTime::Format::Alami::parse_datetime at line 13
use DateTime::Helpers;
# spent 5µs making 1 call to DateTime::BEGIN@13
143314µs219.2ms
# spent 19.2ms (1.69+17.5) within DateTime::BEGIN@14 which was called: # once (1.69ms+17.5ms) by DateTime::Format::Alami::parse_datetime at line 14
use DateTime::Locale 0.41;
# spent 19.2ms making 1 call to DateTime::BEGIN@14 # spent 14µs making 1 call to UNIVERSAL::VERSION
153226µs29.74ms
# spent 9.73ms (2.80+6.93) within DateTime::BEGIN@15 which was called: # once (2.80ms+6.93ms) by DateTime::Format::Alami::parse_datetime at line 15
use DateTime::TimeZone 1.74;
# spent 9.73ms making 1 call to DateTime::BEGIN@15 # spent 9µs making 1 call to UNIVERSAL::VERSION
16
# spent 63µs (12+51) within DateTime::BEGIN@16 which was called: # once (12µs+51µs) by DateTime::Format::Alami::parse_datetime at line 17
use Params::Validate 1.03
17340µs3115µs qw( validate validate_pos UNDEF SCALAR BOOLEAN HASHREF OBJECT );
# spent 63µs making 1 call to DateTime::BEGIN@16 # spent 45µs making 1 call to Exporter::import # spent 7µs making 1 call to UNIVERSAL::VERSION
182161µs28.05ms
# spent 6.73ms (3.41+3.32) within DateTime::BEGIN@18 which was called: # once (3.41ms+3.32ms) by DateTime::Format::Alami::parse_datetime at line 18
use POSIX qw(floor fmod);
# spent 6.73ms making 1 call to DateTime::BEGIN@18 # spent 1.32ms making 1 call to POSIX::import
192206µs260µs
# spent 34µs (8+26) within DateTime::BEGIN@19 which was called: # once (8µs+26µs) by DateTime::Format::Alami::parse_datetime at line 19
use Try::Tiny;
# spent 34µs making 1 call to DateTime::BEGIN@19 # spent 26µs making 1 call to Exporter::import
20
21{
222800ns my $loaded = 0;
23
2416µs unless ( $ENV{PERL_DATETIME_PP} ) {
25
# spent 211µs (11+200) within DateTime::try {...} which was called: # once (11µs+200µs) by Try::Tiny::try at line 92 of Try/Tiny.pm
try {
261900ns require XSLoader;
27 XSLoader::load(
28 __PACKAGE__,
29 exists $DateTime::{VERSION} && ${ $DateTime::{VERSION} }
301208µs1200µs ? ${ $DateTime::{VERSION} }
# spent 200µs making 1 call to XSLoader::load
31 : 42
32 );
33
341400ns $loaded = 1;
3513µs $DateTime::IsPurePerl = 0;
36 }
37 catch {
38 die $_ if $_ && $_ !~ /object version|loadable object/;
3917µs2255µs };
# spent 234µs making 1 call to Try::Tiny::try # spent 20µs making 1 call to Try::Tiny::catch
40 }
41
421600ns if ($loaded) {
43 require DateTime::PPExtra
44 unless defined &DateTime::_normalize_tai_seconds;
45 }
46 else {
47 require DateTime::PP;
48 }
49}
50
51# for some reason, overloading doesn't work unless fallback is listed
52# early.
53#
54# 3rd parameter ( $_[2] ) means the parameters are 'reversed'.
55# see: "Calling conventions for binary operations" in overload docs.
56#
57
# spent 60µs (9+51) within DateTime::BEGIN@57 which was called: # once (9µs+51µs) by DateTime::Format::Alami::parse_datetime at line 66
use overload (
5816µs151µs 'fallback' => 1,
# spent 51µs making 1 call to overload::import
59 '<=>' => '_compare_overload',
60 'cmp' => '_string_compare_overload',
61 '""' => '_stringify',
62 '-' => '_subtract_overload',
63 '+' => '_add_overload',
64 'eq' => '_string_equals_overload',
65 'ne' => '_string_not_equals_overload',
66131µs160µs);
# spent 60µs making 1 call to DateTime::BEGIN@57
67
68# Have to load this after overloading is defined, after BEGIN blocks
69# or else weird crashes ensue
70191µsrequire DateTime::Infinite;
71
72234µs288µs
# spent 48µs (7+40) within DateTime::BEGIN@72 which was called: # once (7µs+40µs) by DateTime::Format::Alami::parse_datetime at line 72
use constant MAX_NANOSECONDS => 1_000_000_000; # 1E9 = almost 32 bits
# spent 48µs making 1 call to DateTime::BEGIN@72 # spent 40µs making 1 call to constant::import
73
74242µs287µs
# spent 47µs (7+40) within DateTime::BEGIN@74 which was called: # once (7µs+40µs) by DateTime::Format::Alami::parse_datetime at line 74
use constant INFINITY => ( 100**100**100**100 );
# spent 47µs making 1 call to DateTime::BEGIN@74 # spent 40µs making 1 call to constant::import
75234µs272µs
# spent 40µs (8+32) within DateTime::BEGIN@75 which was called: # once (8µs+32µs) by DateTime::Format::Alami::parse_datetime at line 75
use constant NEG_INFINITY => -1 * ( 100**100**100**100 );
# spent 40µs making 1 call to DateTime::BEGIN@75 # spent 32µs making 1 call to constant::import
76225µs262µs
# spent 34µs (7+27) within DateTime::BEGIN@76 which was called: # once (7µs+27µs) by DateTime::Format::Alami::parse_datetime at line 76
use constant NAN => INFINITY - INFINITY;
# spent 34µs making 1 call to DateTime::BEGIN@76 # spent 27µs making 1 call to constant::import
77
78225µs261µs
# spent 34µs (6+27) within DateTime::BEGIN@78 which was called: # once (6µs+27µs) by DateTime::Format::Alami::parse_datetime at line 78
use constant SECONDS_PER_DAY => 86400;
# spent 34µs making 1 call to DateTime::BEGIN@78 # spent 27µs making 1 call to constant::import
79
80258µs258µs
# spent 32µs (6+26) within DateTime::BEGIN@80 which was called: # once (6µs+26µs) by DateTime::Format::Alami::parse_datetime at line 80
use constant duration_class => 'DateTime::Duration';
# spent 32µs making 1 call to DateTime::BEGIN@80 # spent 26µs making 1 call to constant::import
81
821400nsmy ( @MonthLengths, @LeapYearMonthLengths );
83
84
# spent 5µs within DateTime::BEGIN@84 which was called: # once (5µs+0s) by DateTime::Format::Alami::parse_datetime at line 89
BEGIN {
8511µs @MonthLengths = ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
86
871500ns @LeapYearMonthLengths = @MonthLengths;
8814µs $LeapYearMonthLengths[1]++;
8912.59ms15µs}
# spent 5µs making 1 call to DateTime::BEGIN@84
90
91{
92
93 # I'd rather use Class::Data::Inheritable for this, but there's no
94 # way to add the module-loading behavior to an accessor it
95 # creates, despite what its docs say!
962600ns my $DefaultLocale;
97
98
# spent 2.95ms (2.93+13µs) within DateTime::DefaultLocale which was called 3001 times, avg 982ns/call: # 3000 times (2.93ms+0s) by DateTime::_set_locale at line 299, avg 975ns/call # once (6µs+13µs) by DateTime::Format::Alami::parse_datetime at line 113
sub DefaultLocale {
993001444µs my $class = shift;
100
1013001612µs if (@_) {
1021400ns my $lang = shift;
103
10411µs113µs $DefaultLocale = DateTime::Locale->load($lang);
# spent 13µs making 1 call to DateTime::Locale::load
105 }
106
10730015.13ms return $DefaultLocale;
108 }
109
110 # backwards compat
11112µs *DefaultLanguage = \&DefaultLocale;
112}
11312µs120µs__PACKAGE__->DefaultLocale('en_US');
# spent 20µs making 1 call to DateTime::DefaultLocale
114
115my $BasicValidate = {
116 year => {
117 type => SCALAR,
118 callbacks => {
119600035.9ms60005.48ms
# spent 25.3ms (19.8+5.48) within DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:119] which was called 6000 times, avg 4µs/call: # 6000 times (19.8ms+5.48ms) by Params::Validate::XS::validate at line 197, avg 4µs/call
'is an integer' => sub { $_[0] =~ /^-?\d+$/ }
# spent 5.48ms making 6000 calls to DateTime::CORE:match, avg 913ns/call
120 },
121 },
122 month => {
123 type => SCALAR,
124 default => 1,
125 callbacks => {
126 'an integer between 1 and 12' =>
127900064.1ms90007.66ms
# spent 39.9ms (32.2+7.66) within DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:127] which was called 9000 times, avg 4µs/call: # 6000 times (23.5ms+3.89ms) by Params::Validate::XS::validate at line 197, avg 5µs/call # 3000 times (8.66ms+3.76ms) by Params::Validate::XS::validate at line 1954, avg 4µs/call
sub { $_[0] =~ /^\d+$/ && $_[0] >= 1 && $_[0] <= 12 }
# spent 7.66ms making 9000 calls to DateTime::CORE:match, avg 851ns/call
128 },
129 },
130 day => {
131 type => SCALAR,
132 default => 1,
133 callbacks => {
134 'an integer which is a possible valid day of month' =>
135900074.1ms90007.69ms
# spent 38.3ms (30.6+7.69) within DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:135] which was called 9000 times, avg 4µs/call: # 6000 times (17.6ms+4.20ms) by Params::Validate::XS::validate at line 197, avg 4µs/call # 3000 times (13.0ms+3.49ms) by Params::Validate::XS::validate at line 1954, avg 5µs/call
sub { $_[0] =~ /^\d+$/ && $_[0] >= 1 && $_[0] <= 31 }
# spent 7.69ms making 9000 calls to DateTime::CORE:match, avg 855ns/call
136 },
137 },
138 hour => {
139 type => SCALAR,
140 default => 0,
141 callbacks => {
142 'an integer between 0 and 23' =>
143600042.4ms60004.61ms
# spent 25.1ms (20.5+4.61) within DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:143] which was called 6000 times, avg 4µs/call: # 6000 times (20.5ms+4.61ms) by Params::Validate::XS::validate at line 197, avg 4µs/call
sub { $_[0] =~ /^\d+$/ && $_[0] >= 0 && $_[0] <= 23 },
# spent 4.61ms making 6000 calls to DateTime::CORE:match, avg 769ns/call
144 },
145 },
146 minute => {
147 type => SCALAR,
148 default => 0,
149 callbacks => {
150 'an integer between 0 and 59' =>
151600037.4ms60004.11ms
# spent 18.4ms (14.2+4.11) within DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:151] which was called 6000 times, avg 3µs/call: # 6000 times (14.2ms+4.11ms) by Params::Validate::XS::validate at line 197, avg 3µs/call
sub { $_[0] =~ /^\d+$/ && $_[0] >= 0 && $_[0] <= 59 },
# spent 4.11ms making 6000 calls to DateTime::CORE:match, avg 686ns/call
152 },
153 },
154 second => {
155 type => SCALAR,
156 default => 0,
157 callbacks => {
158 'an integer between 0 and 61' =>
159600052.9ms60003.91ms
# spent 26.5ms (22.6+3.91) within DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:159] which was called 6000 times, avg 4µs/call: # 6000 times (22.6ms+3.91ms) by Params::Validate::XS::validate at line 197, avg 4µs/call
sub { $_[0] =~ /^\d+$/ && $_[0] >= 0 && $_[0] <= 61 },
# spent 3.91ms making 6000 calls to DateTime::CORE:match, avg 651ns/call
160 },
161 },
162 nanosecond => {
163 type => SCALAR,
164 default => 0,
165 callbacks => {
166600048.2ms60003.77ms
# spent 24.7ms (20.9+3.77) within DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:166] which was called 6000 times, avg 4µs/call: # 6000 times (20.9ms+3.77ms) by Params::Validate::XS::validate at line 197, avg 4µs/call
'a positive integer' => sub { $_[0] =~ /^\d+$/ && $_[0] >= 0 },
# spent 3.77ms making 6000 calls to DateTime::CORE:match, avg 629ns/call
167 }
168 },
169 locale => {
170 type => SCALAR | OBJECT,
171 default => undef
172 },
173 language => {
174 type => SCALAR | OBJECT,
175 optional => 1
176 },
177 formatter => {
178 type => UNDEF | SCALAR | OBJECT,
179 optional => 1,
180 callbacks => {
181 'can format_datetime' =>
182 sub { defined $_[0] ? $_[0]->can('format_datetime') : 1 },
183 },
184 },
185125µs};
186
18714µsmy $NewValidate = {
188 %$BasicValidate,
189 time_zone => {
190 type => SCALAR | OBJECT,
191 optional => 1,
192 },
193};
194
195
# spent 940ms (65.6+875) within DateTime::new which was called 6000 times, avg 157µs/call: # 6000 times (65.6ms+875ms) by DateTime::_new_from_self at line 324, avg 157µs/call
sub new {
1966000847µs my $class = shift;
1976000244ms48000676ms my %p = validate( @_, $NewValidate );
# spent 507ms making 6000 calls to Params::Validate::XS::validate, avg 84µs/call # spent 27.4ms making 6000 calls to DateTime::__ANON__[DateTime.pm:127], avg 5µs/call # spent 26.5ms making 6000 calls to DateTime::__ANON__[DateTime.pm:159], avg 4µs/call # spent 25.3ms making 6000 calls to DateTime::__ANON__[DateTime.pm:119], avg 4µs/call # spent 25.1ms making 6000 calls to DateTime::__ANON__[DateTime.pm:143], avg 4µs/call # spent 24.7ms making 6000 calls to DateTime::__ANON__[DateTime.pm:166], avg 4µs/call # spent 21.8ms making 6000 calls to DateTime::__ANON__[DateTime.pm:135], avg 4µs/call # spent 18.4ms making 6000 calls to DateTime::__ANON__[DateTime.pm:151], avg 3µs/call
198
199 Carp::croak(
200 "Invalid day of month (day = $p{day} - month = $p{month} - year = $p{year})\n"
201 )
202 if $p{day} > 28
20360001.80ms && $p{day} > $class->_month_length( $p{year}, $p{month} );
204
205600027.3ms6000368ms return $class->_new(%p);
# spent 368ms making 6000 calls to DateTime::_new, avg 61µs/call
206}
207
208
# spent 908ms (362+546) within DateTime::_new which was called 13000 times, avg 70µs/call: # 6000 times (155ms+213ms) by DateTime::new at line 205, avg 61µs/call # 4000 times (115ms+147ms) by DateTime::_new_from_self at line 324, avg 66µs/call # 3000 times (91.2ms+186ms) by DateTime::from_epoch at line 536, avg 93µs/call
sub _new {
209130002.66ms my $class = shift;
2101300017.5ms my %p = @_;
211
212130001.70ms Carp::croak('Constructor called with reference, we expected a package')
213 if ref $class;
214
215 # If this method is called from somewhere other than new(), then some of
216 # these defaults may not get applied.
217130002.37ms $p{month} = 1 unless exists $p{month};
218130001.26ms $p{day} = 1 unless exists $p{day};
219130001.07ms $p{hour} = 0 unless exists $p{hour};
220130001.17ms $p{minute} = 0 unless exists $p{minute};
221130001.10ms $p{second} = 0 unless exists $p{second};
222130001.80ms $p{nanosecond} = 0 unless exists $p{nanosecond};
22313000998µs $p{time_zone} = $class->_default_time_zone unless exists $p{time_zone};
224
225130006.14ms my $self = bless {}, $class;
226
227130001.44ms $p{locale} = delete $p{language} if exists $p{language};
228
2291300012.1ms1300030.3ms $self->_set_locale( $p{locale} );
# spent 30.3ms making 13000 calls to DateTime::_set_locale, avg 2µs/call
230
231 $self->{tz} = (
232 ref $p{time_zone}
233 ? $p{time_zone}
234 : DateTime::TimeZone->new( name => $p{time_zone} )
235130009.79ms300065.6ms );
# spent 65.6ms making 3000 calls to DateTime::TimeZone::new, avg 22µs/call
236
2371300046.5ms130008.09ms $self->{local_rd_days} = $class->_ymd2rd( @p{qw( year month day )} );
# spent 8.09ms making 13000 calls to DateTime::_ymd2rd, avg 623ns/call
238
239 $self->{local_rd_secs}
2401300032.3ms130005.64ms = $class->_time_as_seconds( @p{qw( hour minute second )} );
# spent 5.64ms making 13000 calls to DateTime::_time_as_seconds, avg 434ns/call
241
242130002.20ms $self->{offset_modifier} = 0;
243
244130003.36ms $self->{rd_nanosecs} = $p{nanosecond};
245130002.76ms $self->{formatter} = $p{formatter};
246
247 $self->_normalize_nanoseconds(
248 $self->{local_rd_secs},
249 $self->{rd_nanosecs}
2501300010.9ms130009.87ms );
# spent 9.87ms making 13000 calls to DateTime::_normalize_nanoseconds, avg 760ns/call
251
252 # Set this explicitly since it can't be calculated accurately
253 # without knowing our time zone offset, and it's possible that the
254 # offset can't be calculated without having at least a rough guess
255 # of the datetime's year. This year need not be correct, as long
256 # as its equal or greater to the correct number, so we fudge by
257 # adding one to the local year given to the constructor.
2581300010.9ms $self->{utc_year} = $p{year} + 1;
259
260130009.86ms1300014.3ms $self->_maybe_future_dst_warning( $p{year}, $p{time_zone} );
# spent 14.3ms making 13000 calls to DateTime::_maybe_future_dst_warning, avg 1µs/call
261
262130008.53ms1300082.2ms $self->_calc_utc_rd;
# spent 82.2ms making 13000 calls to DateTime::_calc_utc_rd, avg 6µs/call
263
264130009.45ms13000144ms $self->_handle_offset_modifier( $p{second} );
# spent 144ms making 13000 calls to DateTime::_handle_offset_modifier, avg 11µs/call
265
2661300010.5ms13000186ms $self->_calc_local_rd;
# spent 186ms making 13000 calls to DateTime::_calc_local_rd, avg 14µs/call
267
268130003.27ms if ( $p{second} > 59 ) {
269 if (
270 $self->{tz}->is_floating
271 ||
272
273 # If true, this means that the actual calculated leap
274 # second does not occur in the second given to new()
275 ( $self->{utc_rd_secs} - 86399 < $p{second} - 59 )
276 ) {
277 Carp::croak("Invalid second value ($p{second})\n");
278 }
279 }
280
2811300027.9ms return $self;
282}
283
284# Warning: do not use this environment variable unless you have no choice in
285# the matter.
286sub _default_time_zone {
287 return $ENV{PERL_DATETIME_DEFAULT_TZ} || 'floating';
288}
289
290
# spent 30.3ms (27.4+2.93) within DateTime::_set_locale which was called 13000 times, avg 2µs/call: # 13000 times (27.4ms+2.93ms) by DateTime::_new at line 229, avg 2µs/call
sub _set_locale {
291130001.43ms my $self = shift;
292130002.24ms my $locale = shift;
293
294130007.43ms if ( defined $locale && ref $locale ) {
295 $self->{locale} = $locale;
296 }
297 else {
298 $self->{locale}
29930003.68ms30002.93ms = $locale
# spent 2.93ms making 3000 calls to DateTime::DefaultLocale, avg 975ns/call
300 ? DateTime::Locale->load($locale)
301 : $self->DefaultLocale();
302 }
303
3041300030.5ms return;
305}
306
307# This method exists for the benefit of internal methods which create
308# a new object based on the current object, like set() and truncate().
309
# spent 1.57s (302ms+1.27) within DateTime::_new_from_self which was called 10000 times, avg 157µs/call: # 6000 times (184ms+983ms) by DateTime::set at line 1956, avg 195µs/call # 4000 times (118ms+289ms) by DateTime::truncate at line 2045, avg 102µs/call
sub _new_from_self {
310100001.86ms my $self = shift;
311100007.38ms my %p = @_;
312
31310000102ms9000064.1ms my %old = map { $_ => $self->$_() } qw(
# spent 9.42ms making 10000 calls to DateTime::year, avg 942ns/call # spent 7.41ms making 10000 calls to DateTime::month, avg 741ns/call # spent 7.03ms making 10000 calls to DateTime::time_zone, avg 703ns/call # spent 6.96ms making 10000 calls to DateTime::day_of_month, avg 696ns/call # spent 6.81ms making 10000 calls to DateTime::minute, avg 681ns/call # spent 6.80ms making 10000 calls to DateTime::hour, avg 680ns/call # spent 6.79ms making 10000 calls to DateTime::locale, avg 679ns/call # spent 6.67ms making 10000 calls to DateTime::nanosecond, avg 667ns/call # spent 6.25ms making 10000 calls to DateTime::second, avg 625ns/call
314 year month day
315 hour minute second
316 nanosecond
317 locale time_zone
318 );
319100008.28ms100006.21ms $old{formatter} = $self->formatter()
# spent 6.21ms making 10000 calls to DateTime::formatter, avg 621ns/call
320 if defined $self->formatter();
321
322100004.50ms my $method = delete $p{_skip_validation} ? '_new' : 'new';
323
3241000052.5ms100001.20s return ( ref $self )->$method( %old, %p );
# spent 940ms making 6000 calls to DateTime::new, avg 157µs/call # spent 262ms making 4000 calls to DateTime::_new, avg 66µs/call
325}
326
327
# spent 144ms (94.5+49.4) within DateTime::_handle_offset_modifier which was called 13000 times, avg 11µs/call: # 13000 times (94.5ms+49.4ms) by DateTime::_new at line 264, avg 11µs/call
sub _handle_offset_modifier {
328130002.37ms my $self = shift;
329
330130002.67ms $self->{offset_modifier} = 0;
331
3321300010.5ms130006.31ms return if $self->{tz}->is_floating;
# spent 6.31ms making 13000 calls to DateTime::TimeZone::is_floating, avg 485ns/call
333
334130002.03ms my $second = shift;
335130001.52ms my $utc_is_valid = shift;
336
337130002.75ms my $utc_rd_days = $self->{utc_rd_days};
338
3391300010.5ms1300043.1ms my $offset
# spent 43.1ms making 13000 calls to DateTime::_offset_for_local_datetime, avg 3µs/call
340 = $utc_is_valid ? $self->offset : $self->_offset_for_local_datetime;
341
3421300037.7ms if ( $offset >= 0
343 && $self->{local_rd_secs} >= $offset ) {
344130005.06ms if ( $second < 60 && $offset > 0 ) {
345 $self->{offset_modifier}
346 = $self->_day_length( $utc_rd_days - 1 ) - SECONDS_PER_DAY;
347
348 $self->{local_rd_secs} += $self->{offset_modifier};
349 }
350 elsif (
351 $second == 60
352 && (
353 ( $self->{local_rd_secs} == $offset && $offset > 0 )
354 || ( $offset == 0
355 && $self->{local_rd_secs} > 86399 )
356 )
357 ) {
358 my $mod
359 = $self->_day_length( $utc_rd_days - 1 ) - SECONDS_PER_DAY;
360
361 unless ( $mod == 0 ) {
362 $self->{utc_rd_secs} -= $mod;
363
364 $self->_normalize_seconds;
365 }
366 }
367 }
368 elsif ($offset < 0
369 && $self->{local_rd_secs} >= SECONDS_PER_DAY + $offset ) {
370 if ( $second < 60 ) {
371 $self->{offset_modifier}
372 = $self->_day_length( $utc_rd_days - 1 ) - SECONDS_PER_DAY;
373
374 $self->{local_rd_secs} += $self->{offset_modifier};
375 }
376 elsif ($second == 60
377 && $self->{local_rd_secs} == SECONDS_PER_DAY + $offset ) {
378 my $mod
379 = $self->_day_length( $utc_rd_days - 1 ) - SECONDS_PER_DAY;
380
381 unless ( $mod == 0 ) {
382 $self->{utc_rd_secs} -= $mod;
383
384 $self->_normalize_seconds;
385 }
386 }
387 }
388}
389
390
# spent 82.4ms (67.6+14.8) within DateTime::_calc_utc_rd which was called 13002 times, avg 6µs/call: # 13000 times (67.4ms+14.8ms) by DateTime::_new at line 262, avg 6µs/call # once (67µs+6µs) by DateTime::Format::Alami::parse_datetime at line 89 of DateTime/Infinite.pm # once (40µs+2µs) by DateTime::Format::Alami::parse_datetime at line 114 of DateTime/Infinite.pm
sub _calc_utc_rd {
391130021.51ms my $self = shift;
392
393130022.64ms delete $self->{utc_c};
394
3951300211.8ms130046.14ms if ( $self->{tz}->is_utc || $self->{tz}->is_floating ) {
# spent 6.13ms making 13000 calls to DateTime::TimeZone::UTC::is_utc, avg 472ns/call # spent 2µs making 2 calls to DateTime::TimeZone::Floating::is_floating, avg 1µs/call # spent 2µs making 2 calls to DateTime::TimeZone::OffsetOnly::is_utc, avg 1µs/call
396130023.84ms $self->{utc_rd_days} = $self->{local_rd_days};
397130023.88ms $self->{utc_rd_secs} = $self->{local_rd_secs};
398 }
399 else {
400 my $offset = $self->_offset_for_local_datetime;
401
402 $offset += $self->{offset_modifier};
403
404 $self->{utc_rd_days} = $self->{local_rd_days};
405 $self->{utc_rd_secs} = $self->{local_rd_secs} - $offset;
406 }
407
408 # We account for leap seconds in the new() method and nowhere else
409 # except date math.
410 $self->_normalize_tai_seconds(
411 $self->{utc_rd_days},
412 $self->{utc_rd_secs}
4131300255.2ms130028.66ms );
# spent 8.66ms making 13002 calls to DateTime::_normalize_tai_seconds, avg 666ns/call
414}
415
416sub _normalize_seconds {
417 my $self = shift;
418
419 return if $self->{utc_rd_secs} >= 0 && $self->{utc_rd_secs} <= 86399;
420
421 if ( $self->{tz}->is_floating ) {
422 $self->_normalize_tai_seconds(
423 $self->{utc_rd_days},
424 $self->{utc_rd_secs}
425 );
426 }
427 else {
428 $self->_normalize_leap_seconds(
429 $self->{utc_rd_days},
430 $self->{utc_rd_secs}
431 );
432 }
433}
434
435
# spent 186ms (72.9+113) within DateTime::_calc_local_rd which was called 13002 times, avg 14µs/call: # 13000 times (72.9ms+113ms) by DateTime::_new at line 266, avg 14µs/call # once (17µs+27µs) by DateTime::Format::Alami::parse_datetime at line 90 of DateTime/Infinite.pm # once (10µs+17µs) by DateTime::Format::Alami::parse_datetime at line 115 of DateTime/Infinite.pm
sub _calc_local_rd {
436130021.86ms my $self = shift;
437
438130021.96ms delete $self->{local_c};
439
440 # We must short circuit for UTC times or else we could end up with
441 # loops between DateTime.pm and DateTime::TimeZone
442130029.46ms130044.25ms if ( $self->{tz}->is_utc || $self->{tz}->is_floating ) {
# spent 4.25ms making 13000 calls to DateTime::TimeZone::UTC::is_utc, avg 327ns/call # spent 1µs making 2 calls to DateTime::TimeZone::Floating::is_floating, avg 600ns/call # spent 1µs making 2 calls to DateTime::TimeZone::OffsetOnly::is_utc, avg 500ns/call
443130023.97ms $self->{local_rd_days} = $self->{utc_rd_days};
444130023.32ms $self->{local_rd_secs} = $self->{utc_rd_secs};
445 }
446 else {
447 my $offset = $self->offset;
448
449 $self->{local_rd_days} = $self->{utc_rd_days};
450 $self->{local_rd_secs} = $self->{utc_rd_secs} + $offset;
451
452 # intentionally ignore leap seconds here
453 $self->_normalize_tai_seconds(
454 $self->{local_rd_days},
455 $self->{local_rd_secs}
456 );
457
458 $self->{local_rd_secs} += $self->{offset_modifier};
459 }
460
4611300235.1ms13002109ms $self->_calc_local_components;
# spent 109ms making 13002 calls to DateTime::_calc_local_components, avg 8µs/call
462}
463
464
# spent 109ms (94.4+14.8) within DateTime::_calc_local_components which was called 13002 times, avg 8µs/call: # 13002 times (94.4ms+14.8ms) by DateTime::_calc_local_rd at line 461, avg 8µs/call
sub _calc_local_components {
465130021.47ms my $self = shift;
466
467 @{ $self->{local_c} }{
468 qw( year month day day_of_week
469 day_of_year quarter day_of_quarter)
470 }
4711300251.5ms130028.17ms = $self->_rd2ymd( $self->{local_rd_days}, 1 );
# spent 8.17ms making 13000 calls to DateTime::_rd2ymd, avg 628ns/call # spent 5µs making 2 calls to DateTime::Infinite::_rd2ymd, avg 3µs/call
472
473 @{ $self->{local_c} }{qw( hour minute second )}
474 = $self->_seconds_as_components(
475 $self->{local_rd_secs},
476 $self->{utc_rd_secs}, $self->{offset_modifier}
4771300274.8ms130026.58ms );
# spent 6.58ms making 13000 calls to DateTime::_seconds_as_components, avg 506ns/call # spent 3µs making 2 calls to DateTime::Infinite::_seconds_as_components, avg 1µs/call
478}
479
480{
48117µs13µs my $float = qr/
# spent 3µs making 1 call to DateTime::CORE:qr
482 ^ -? (?: [0-9]+ (?: \.[0-9]*)? | \. [0-9]+) (?: [eE][+-]?[0-9]+)? $
483 /x;
48415µs my $spec = {
485 epoch => { regex => $float },
486 locale => { type => SCALAR | OBJECT, optional => 1 },
487 language => { type => SCALAR | OBJECT, optional => 1 },
488 time_zone => { type => SCALAR | OBJECT, optional => 1 },
489 formatter => {
490 type => SCALAR | OBJECT, can => 'format_datetime',
491 optional => 1
492 },
493 };
494
495
# spent 414ms (71.7+343) within DateTime::from_epoch which was called 3000 times, avg 138µs/call: # 3000 times (71.7ms+343ms) by DateTime::now at line 549, avg 138µs/call
sub from_epoch {
4963000487µs my $class = shift;
497300044.5ms600082.9ms my %p = validate( @_, $spec );
# spent 56.7ms making 3000 calls to Params::Validate::XS::validate, avg 19µs/call # spent 26.2ms making 3000 calls to Params::Validate::XS::_check_regex_from_xs, avg 9µs/call
498
4993000330µs my %args;
500
501 # This does two things. First, if given a negative non-integer epoch,
502 # it will round the epoch _down_ to the next second and then adjust
503 # the nanoseconds to be positive. In other words, -0.5 corresponds to
504 # a second of -1 and a nanosecond value of 500,000. Before this code
505 # was implemented our handling of negative non-integer epochs was
506 # quite broken, and would end up rounding some values up, so that -0.5
507 # become 0.5 (which is obviously wrong!).
508 #
509 # Second, it rounds any decimal values to the nearest millisecond
510 # (1E6). Here's what Christian Hanse, who wrote this patch, says:
511 #
512 # Perl is typically compiled with NV as a double. A double with a
513 # significand precision of 53 bits can only represent a nanosecond
514 # epoch without loss of precision if the duration from zero epoch
515 # is less than ≈ ±104 days. With microseconds the duration is
516 # ±104,000 days, which is ~ ±285 years.
51730009.16ms30001.70ms if ( $p{epoch} =~ /[.eE]/ ) {
# spent 1.70ms making 3000 calls to DateTime::CORE:match, avg 566ns/call
518 my ( $floor, $nano, $second );
519
520 $floor = $nano = fmod( $p{epoch}, 1.0 );
521 $second = floor( $p{epoch} - $floor );
522 if ( $nano < 0 ) {
523 $nano += 1;
524 }
525 $p{epoch} = $second + floor( $floor - $nano );
526 $args{nanosecond} = floor( $nano * 1E6 + 0.5 ) * 1E3;
527 }
528
529 # Note, for very large negative values this may give a
530 # blatantly wrong answer.
531 @args{qw( second minute hour day month year )}
53230009.41ms = ( gmtime( $p{epoch} ) )[ 0 .. 5 ];
53330001.42ms $args{year} += 1900;
5343000450µs $args{month}++;
535
53630005.96ms3000278ms my $self = $class->_new( %p, %args, time_zone => 'UTC' );
# spent 278ms making 3000 calls to DateTime::_new, avg 93µs/call
537
5383000631µs my $tz = $p{time_zone};
53930006.35ms60006.74ms $self->_maybe_future_dst_warning( $self->year(), $p{time_zone} );
# spent 3.71ms making 3000 calls to DateTime::_maybe_future_dst_warning, avg 1µs/call # spent 3.03ms making 3000 calls to DateTime::year, avg 1µs/call
540
5413000515µs $self->set_time_zone( $p{time_zone} ) if exists $p{time_zone};
542
543300010.1ms return $self;
544 }
545}
546
5471500ns
# spent 434ms (18.2+416) within DateTime::now which was called 3000 times, avg 145µs/call: # 3000 times (18.2ms+416ms) by DateTime::today at line 573, avg 145µs/call
sub now {
5483000512µs my $class = shift;
54930007.03ms6000416ms return $class->from_epoch( epoch => $class->_core_time(), @_ );
# spent 414ms making 3000 calls to DateTime::from_epoch, avg 138µs/call # spent 1.84ms making 3000 calls to DateTime::_core_time, avg 614ns/call
550}
551
552
# spent 18.0ms within DateTime::_maybe_future_dst_warning which was called 16000 times, avg 1µs/call: # 13000 times (14.3ms+0s) by DateTime::_new at line 260, avg 1µs/call # 3000 times (3.71ms+0s) by DateTime::from_epoch at line 539, avg 1µs/call
sub _maybe_future_dst_warning {
553160001.61ms shift;
554160002.25ms my $year = shift;
555160002.47ms my $tz = shift;
556
5571600047.8ms return unless $year >= 5000 && $tz;
558
559 my $tz_name = ref $tz ? $tz->name() : $tz;
560 return if $tz_name eq 'floating' || $tz_name eq 'UTC';
561
562 warnings::warnif(
563 "You are creating a DateTime object with a far future year ($year) and a time zone ($tz_name)."
564 . ' If the time zone you specified has future DST changes this will be very slow.'
565 );
566}
567
568# use scalar time in case someone's loaded Time::Piece
569
# spent 1.84ms within DateTime::_core_time which was called 3000 times, avg 614ns/call: # 3000 times (1.84ms+0s) by DateTime::now at line 549, avg 614ns/call
sub _core_time {
57030008.18ms return scalar time;
571}
572
57330007.78ms6000874ms
# spent 890ms (16.2+874) within DateTime::today which was called 3000 times, avg 297µs/call: # 3000 times (16.2ms+874ms) by DateTime::Format::Alami::a_today at line 460 of lib/DateTime/Format/Alami.pm, avg 297µs/call
sub today { shift->now(@_)->truncate( to => 'day' ) }
# spent 439ms making 3000 calls to DateTime::truncate, avg 146µs/call # spent 434ms making 3000 calls to DateTime::now, avg 145µs/call
574
575{
57614µs my $spec = {
577 object => {
578 type => OBJECT,
579 can => 'utc_rd_values',
580 },
581 locale => { type => SCALAR | OBJECT, optional => 1 },
582 language => { type => SCALAR | OBJECT, optional => 1 },
583 formatter => {
584 type => SCALAR | OBJECT, can => 'format_datetime',
585 optional => 1
586 },
587 };
588
589 sub from_object {
590 my $class = shift;
591 my %p = validate( @_, $spec );
592
593 my $object = delete $p{object};
594
595 if ( $object->isa('DateTime::Infinite') ) {
596 return $object->clone;
597 }
598
599 my ( $rd_days, $rd_secs, $rd_nanosecs ) = $object->utc_rd_values;
600
601 # A kludge because until all calendars are updated to return all
602 # three values, $rd_nanosecs could be undef
603 $rd_nanosecs ||= 0;
604
605 # This is a big hack to let _seconds_as_components operate naively
606 # on the given value. If the object _is_ on a leap second, we'll
607 # add that to the generated seconds value later.
608 my $leap_seconds = 0;
609 if ( $object->can('time_zone')
610 && !$object->time_zone->is_floating
611 && $rd_secs > 86399
612 && $rd_secs <= $class->_day_length($rd_days) ) {
613 $leap_seconds = $rd_secs - 86399;
614 $rd_secs -= $leap_seconds;
615 }
616
617 my %args;
618 @args{qw( year month day )} = $class->_rd2ymd($rd_days);
619 @args{qw( hour minute second )}
620 = $class->_seconds_as_components($rd_secs);
621 $args{nanosecond} = $rd_nanosecs;
622
623 $args{second} += $leap_seconds;
624
625 my $new = $class->new( %p, %args, time_zone => 'UTC' );
626
627 if ( $object->can('time_zone') ) {
628 $new->set_time_zone( $object->time_zone );
629 }
630 else {
631 $new->set_time_zone( $class->_default_time_zone );
632 }
633
634 return $new;
635 }
636}
637
63824µsmy $LastDayOfMonthValidate = {%$NewValidate};
63912µsforeach ( keys %$LastDayOfMonthValidate ) {
6401111µs my %copy = %{ $LastDayOfMonthValidate->{$_} };
641
642112µs delete $copy{default};
643114µs $copy{optional} = 1 unless $_ eq 'year' || $_ eq 'month';
644
645114µs $LastDayOfMonthValidate->{$_} = \%copy;
646}
647
648sub last_day_of_month {
649 my $class = shift;
650 my %p = validate( @_, $LastDayOfMonthValidate );
651
652 my $day = $class->_month_length( $p{year}, $p{month} );
653
654 return $class->_new( %p, day => $day );
655}
656
657sub _month_length {
658 return (
659 $_[0]->_is_leap_year( $_[1] )
660 ? $LeapYearMonthLengths[ $_[2] - 1 ]
661 : $MonthLengths[ $_[2] - 1 ]
662 );
663}
664
66512µsmy $FromDayOfYearValidate = {%$NewValidate};
66612µsforeach ( keys %$FromDayOfYearValidate ) {
667112µs next if $_ eq 'month' || $_ eq 'day';
668
66998µs my %copy = %{ $FromDayOfYearValidate->{$_} };
670
67191µs delete $copy{default};
67292µs $copy{optional} = 1 unless $_ eq 'year' || $_ eq 'month';
673
67493µs $FromDayOfYearValidate->{$_} = \%copy;
675}
676$FromDayOfYearValidate->{day_of_year} = {
677 type => SCALAR,
678 callbacks => {
679 'is between 1 and 366' => sub { $_[0] >= 1 && $_[0] <= 366 }
680 }
68113µs};
682
683sub from_day_of_year {
684 my $class = shift;
685 my %p = validate( @_, $FromDayOfYearValidate );
686
687 Carp::croak("$p{year} is not a leap year.\n")
688 if $p{day_of_year} == 366 && !$class->_is_leap_year( $p{year} );
689
690 my $month = 1;
691 my $day = delete $p{day_of_year};
692
693 if ( $day > 31 ) {
694 my $length = $class->_month_length( $p{year}, $month );
695
696 while ( $day > $length ) {
697 $day -= $length;
698 $month++;
699 $length = $class->_month_length( $p{year}, $month );
700 }
701 }
702
703 return $class->_new(
704 %p,
705 month => $month,
706 day => $day,
707 );
708}
709
7101000015.5ms
# spent 6.21ms within DateTime::formatter which was called 10000 times, avg 621ns/call: # 10000 times (6.21ms+0s) by DateTime::_new_from_self at line 319, avg 621ns/call
sub formatter { $_[0]->{formatter} }
711
712sub clone { bless { %{ $_[0] } }, ref $_[0] }
713
714
# spent 16.8ms within DateTime::year which was called 17000 times, avg 991ns/call: # 10000 times (9.42ms+0s) by DateTime::_new_from_self at line 313, avg 942ns/call # 4000 times (4.40ms+0s) by DateTime::truncate at line 2039, avg 1µs/call # 3000 times (3.03ms+0s) by DateTime::from_epoch at line 539, avg 1µs/call
sub year {
715170003.87ms Carp::carp('year() is a read-only accessor') if @_ > 1;
7161700037.9ms return $_[0]->{local_c}{year};
717}
718
719sub ce_year {
720 $_[0]->{local_c}{year} <= 0
721 ? $_[0]->{local_c}{year} - 1
722 : $_[0]->{local_c}{year};
723}
724
725sub era_name { $_[0]->{locale}->era_wide->[ $_[0]->_era_index() ] }
726
727sub era_abbr { $_[0]->{locale}->era_abbreviated->[ $_[0]->_era_index() ] }
728
729# deprecated
73012µs*era = \&era_abbr;
731
732sub _era_index { $_[0]->{local_c}{year} <= 0 ? 0 : 1 }
733
734sub christian_era { $_[0]->ce_year > 0 ? 'AD' : 'BC' }
735sub secular_era { $_[0]->ce_year > 0 ? 'CE' : 'BCE' }
736
737sub year_with_era { ( abs $_[0]->ce_year ) . $_[0]->era_abbr }
738sub year_with_christian_era { ( abs $_[0]->ce_year ) . $_[0]->christian_era }
739sub year_with_secular_era { ( abs $_[0]->ce_year ) . $_[0]->secular_era }
740
741
# spent 10.8ms within DateTime::month which was called 14000 times, avg 774ns/call: # 10000 times (7.41ms+0s) by DateTime::_new_from_self at line 313, avg 741ns/call # 4000 times (3.44ms+0s) by DateTime::truncate at line 2039, avg 859ns/call
sub month {
742140002.41ms Carp::carp('month() is a read-only accessor') if @_ > 1;
7431400031.4ms return $_[0]->{local_c}{month};
744}
74511µs*mon = \&month;
746
747sub month_0 { $_[0]->{local_c}{month} - 1 }
74811µs*mon_0 = \&month_0;
749
750sub month_name { $_[0]->{locale}->month_format_wide->[ $_[0]->month_0() ] }
751
752sub month_abbr {
753 $_[0]->{locale}->month_format_abbreviated->[ $_[0]->month_0() ];
754}
755
756
# spent 10.3ms within DateTime::day_of_month which was called 14000 times, avg 736ns/call: # 10000 times (6.96ms+0s) by DateTime::_new_from_self at line 313, avg 696ns/call # 4000 times (3.34ms+0s) by DateTime::truncate at line 2039, avg 834ns/call
sub day_of_month {
757140002.35ms Carp::carp('day_of_month() is a read-only accessor') if @_ > 1;
7581400026.8ms $_[0]->{local_c}{day};
759}
7601800ns*day = \&day_of_month;
7611800ns*mday = \&day_of_month;
762
76326.73ms2369µs
# spent 366µs (363+3) within DateTime::BEGIN@763 which was called: # once (363µs+3µs) by DateTime::Format::Alami::parse_datetime at line 763
sub weekday_of_month { use integer; ( ( $_[0]->day - 1 ) / 7 ) + 1 }
# spent 366µs making 1 call to DateTime::BEGIN@763 # spent 3µs making 1 call to integer::import
764
765sub quarter { $_[0]->{local_c}{quarter} }
766
767sub quarter_name {
768 $_[0]->{locale}->quarter_format_wide->[ $_[0]->quarter_0() ];
769}
770
771sub quarter_abbr {
772 $_[0]->{locale}->quarter_format_abbreviated->[ $_[0]->quarter_0() ];
773}
774
775sub quarter_0 { $_[0]->{local_c}{quarter} - 1 }
776
777sub day_of_month_0 { $_[0]->{local_c}{day} - 1 }
7781800ns*day_0 = \&day_of_month_0;
7791700ns*mday_0 = \&day_of_month_0;
780
781sub day_of_week { $_[0]->{local_c}{day_of_week} }
7821900ns*wday = \&day_of_week;
7831800ns*dow = \&day_of_week;
784
785sub day_of_week_0 { $_[0]->{local_c}{day_of_week} - 1 }
7861900ns*wday_0 = \&day_of_week_0;
7871700ns*dow_0 = \&day_of_week_0;
788
789sub local_day_of_week {
790 my $self = shift;
791 return 1
792 + ( $self->day_of_week - $self->{locale}->first_day_of_week ) % 7;
793}
794
795sub day_name { $_[0]->{locale}->day_format_wide->[ $_[0]->day_of_week_0() ] }
796
797sub day_abbr {
798 $_[0]->{locale}->day_format_abbreviated->[ $_[0]->day_of_week_0() ];
799}
800
801sub day_of_quarter { $_[0]->{local_c}{day_of_quarter} }
8021800ns*doq = \&day_of_quarter;
803
804sub day_of_quarter_0 { $_[0]->day_of_quarter - 1 }
8051800ns*doq_0 = \&day_of_quarter_0;
806
807sub day_of_year { $_[0]->{local_c}{day_of_year} }
8081900ns*doy = \&day_of_year;
809
810sub day_of_year_0 { $_[0]->{local_c}{day_of_year} - 1 }
8111900ns*doy_0 = \&day_of_year_0;
812
813sub am_or_pm {
814 $_[0]->{locale}->am_pm_abbreviated->[ $_[0]->hour() < 12 ? 0 : 1 ];
815}
816
817sub ymd {
818 my ( $self, $sep ) = @_;
819 $sep = '-' unless defined $sep;
820
821 return sprintf(
822 '%0.4d%s%0.2d%s%0.2d',
823 $self->year, $sep,
824 $self->{local_c}{month}, $sep,
825 $self->{local_c}{day}
826 );
827}
82812µs*date = sub { shift->ymd(@_) };
829
830sub mdy {
831 my ( $self, $sep ) = @_;
832 $sep = '-' unless defined $sep;
833
834 return sprintf(
835 '%0.2d%s%0.2d%s%0.4d',
836 $self->{local_c}{month}, $sep,
837 $self->{local_c}{day}, $sep,
838 $self->year
839 );
840}
841
842sub dmy {
843 my ( $self, $sep ) = @_;
844 $sep = '-' unless defined $sep;
845
846 return sprintf(
847 '%0.2d%s%0.2d%s%0.4d',
848 $self->{local_c}{day}, $sep,
849 $self->{local_c}{month}, $sep,
850 $self->year
851 );
852}
853
854
# spent 6.80ms within DateTime::hour which was called 10000 times, avg 680ns/call: # 10000 times (6.80ms+0s) by DateTime::_new_from_self at line 313, avg 680ns/call
sub hour {
855100001.60ms Carp::carp('hour() is a read-only accessor') if @_ > 1;
8561000010.9ms return $_[0]->{local_c}{hour};
857}
858sub hour_1 { $_[0]->{local_c}{hour} == 0 ? 24 : $_[0]->{local_c}{hour} }
859
860sub hour_12 { my $h = $_[0]->hour % 12; return $h ? $h : 12 }
861sub hour_12_0 { $_[0]->hour % 12 }
862
863
# spent 6.81ms within DateTime::minute which was called 10000 times, avg 681ns/call: # 10000 times (6.81ms+0s) by DateTime::_new_from_self at line 313, avg 681ns/call
sub minute {
864100001.56ms Carp::carp('minute() is a read-only accessor') if @_ > 1;
8651000014.1ms return $_[0]->{local_c}{minute};
866}
8671800ns*min = \&minute;
868
869
# spent 6.25ms within DateTime::second which was called 10000 times, avg 625ns/call: # 10000 times (6.25ms+0s) by DateTime::_new_from_self at line 313, avg 625ns/call
sub second {
870100001.43ms Carp::carp('second() is a read-only accessor') if @_ > 1;
8711000016.3ms return $_[0]->{local_c}{second};
872}
87311µs*sec = \&second;
874
875sub fractional_second { $_[0]->second + $_[0]->nanosecond / MAX_NANOSECONDS }
876
877
# spent 6.67ms within DateTime::nanosecond which was called 10000 times, avg 667ns/call: # 10000 times (6.67ms+0s) by DateTime::_new_from_self at line 313, avg 667ns/call
sub nanosecond {
878100001.56ms Carp::carp('nanosecond() is a read-only accessor') if @_ > 1;
8791000026.7ms return $_[0]->{rd_nanosecs};
880}
881
882sub millisecond { floor( $_[0]->{rd_nanosecs} / 1000000 ) }
883
884sub microsecond { floor( $_[0]->{rd_nanosecs} / 1000 ) }
885
886sub leap_seconds {
887 my $self = shift;
888
889 return 0 if $self->{tz}->is_floating;
890
891 return DateTime->_accumulated_leap_seconds( $self->{utc_rd_days} );
892}
893
894sub _stringify {
895 my $self = shift;
896
897 return $self->iso8601 unless $self->{formatter};
898 return $self->{formatter}->format_datetime($self);
899}
900
901sub hms {
902 my ( $self, $sep ) = @_;
903 $sep = ':' unless defined $sep;
904
905 return sprintf(
906 '%0.2d%s%0.2d%s%0.2d',
907 $self->{local_c}{hour}, $sep,
908 $self->{local_c}{minute}, $sep,
909 $self->{local_c}{second}
910 );
911}
912
913# don't want to override CORE::time()
91412µs*DateTime::time = sub { shift->hms(@_) };
915
916sub iso8601 { join 'T', $_[0]->ymd('-'), $_[0]->hms(':') }
91712µs*datetime = sub { $_[0]->iso8601 };
918
919sub is_leap_year { $_[0]->_is_leap_year( $_[0]->year ) }
920
921sub week {
922 my $self = shift;
923
924 unless ( defined $self->{local_c}{week_year} ) {
925
926 # This algorithm was taken from Date::Calc's DateCalc.c file
927 my $jan_one_dow_m1
928 = ( ( $self->_ymd2rd( $self->year, 1, 1 ) + 6 ) % 7 );
929
930 $self->{local_c}{week_number}
931 = int( ( ( $self->day_of_year - 1 ) + $jan_one_dow_m1 ) / 7 );
932 $self->{local_c}{week_number}++ if $jan_one_dow_m1 < 4;
933
934 if ( $self->{local_c}{week_number} == 0 ) {
935 $self->{local_c}{week_year} = $self->year - 1;
936 $self->{local_c}{week_number}
937 = $self->_weeks_in_year( $self->{local_c}{week_year} );
938 }
939 elsif ($self->{local_c}{week_number} == 53
940 && $self->_weeks_in_year( $self->year ) == 52 ) {
941 $self->{local_c}{week_number} = 1;
942 $self->{local_c}{week_year} = $self->year + 1;
943 }
944 else {
945 $self->{local_c}{week_year} = $self->year;
946 }
947 }
948
949 return @{ $self->{local_c} }{ 'week_year', 'week_number' };
950}
951
952sub _weeks_in_year {
953 my $self = shift;
954 my $year = shift;
955
956 my $dow = $self->_ymd2rd( $year, 1, 1 ) % 7;
957
958 # Years starting with a Thursday and leap years starting with a Wednesday
959 # have 53 weeks.
960 return ( $dow == 4 || ( $dow == 3 && $self->_is_leap_year($year) ) )
961 ? 53
962 : 52;
963}
964
965sub week_year { ( $_[0]->week )[0] }
966sub week_number { ( $_[0]->week )[1] }
967
968# ISO says that the first week of a year is the first week containing
969# a Thursday. Extending that says that the first week of the month is
970# the first week containing a Thursday. ICU agrees.
971sub week_of_month {
972 my $self = shift;
973 my $thu = $self->day + 4 - $self->day_of_week;
974 return int( ( $thu + 6 ) / 7 );
975}
976
977
# spent 7.03ms within DateTime::time_zone which was called 10000 times, avg 703ns/call: # 10000 times (7.03ms+0s) by DateTime::_new_from_self at line 313, avg 703ns/call
sub time_zone {
978100001.59ms Carp::carp('time_zone() is a read-only accessor') if @_ > 1;
9791000026.1ms return $_[0]->{tz};
980}
981
982sub offset { $_[0]->{tz}->offset_for_datetime( $_[0] ) }
983
984
# spent 43.1ms (37.4+5.70) within DateTime::_offset_for_local_datetime which was called 13000 times, avg 3µs/call: # 13000 times (37.4ms+5.70ms) by DateTime::_handle_offset_modifier at line 339, avg 3µs/call
sub _offset_for_local_datetime {
9851300034.2ms130005.70ms $_[0]->{tz}->offset_for_local_datetime( $_[0] );
# spent 5.70ms making 13000 calls to DateTime::TimeZone::UTC::offset_for_local_datetime, avg 438ns/call
986}
987
988sub is_dst { $_[0]->{tz}->is_dst_for_datetime( $_[0] ) }
989
990sub time_zone_long_name { $_[0]->{tz}->name }
991sub time_zone_short_name { $_[0]->{tz}->short_name_for_datetime( $_[0] ) }
992
993
# spent 6.79ms within DateTime::locale which was called 10000 times, avg 679ns/call: # 10000 times (6.79ms+0s) by DateTime::_new_from_self at line 313, avg 679ns/call
sub locale {
994100001.61ms Carp::carp('locale() is a read-only accessor') if @_ > 1;
9951000014.4ms return $_[0]->{locale};
996}
9971900ns*language = \&locale;
998
999sub utc_rd_values {
1000 @{ $_[0] }{ 'utc_rd_days', 'utc_rd_secs', 'rd_nanosecs' };
1001}
1002
1003sub local_rd_values {
1004 @{ $_[0] }{ 'local_rd_days', 'local_rd_secs', 'rd_nanosecs' };
1005}
1006
1007# NOTE: no nanoseconds, no leap seconds
1008sub utc_rd_as_seconds {
1009 ( $_[0]->{utc_rd_days} * SECONDS_PER_DAY ) + $_[0]->{utc_rd_secs};
1010}
1011
1012# NOTE: no nanoseconds, no leap seconds
1013sub local_rd_as_seconds {
1014 ( $_[0]->{local_rd_days} * SECONDS_PER_DAY ) + $_[0]->{local_rd_secs};
1015}
1016
1017# RD 1 is MJD 678,576 - a simple offset
1018sub mjd {
1019 my $self = shift;
1020
1021 my $mjd = $self->{utc_rd_days} - 678_576;
1022
1023 my $day_length = $self->_day_length( $self->{utc_rd_days} );
1024
1025 return ( $mjd
1026 + ( $self->{utc_rd_secs} / $day_length )
1027 + ( $self->{rd_nanosecs} / $day_length / MAX_NANOSECONDS ) );
1028}
1029
1030sub jd { $_[0]->mjd + 2_400_000.5 }
1031
1032{
1033 my %strftime_patterns = (
1034 'a' => sub { $_[0]->day_abbr },
1035 'A' => sub { $_[0]->day_name },
1036 'b' => sub { $_[0]->month_abbr },
1037 'B' => sub { $_[0]->month_name },
1038 'c' => sub {
1039 $_[0]->format_cldr( $_[0]->{locale}->datetime_format_default() );
1040 },
1041 'C' => sub { int( $_[0]->year / 100 ) },
1042 'd' => sub { sprintf( '%02d', $_[0]->day_of_month ) },
1043 'D' => sub { $_[0]->strftime('%m/%d/%y') },
1044 'e' => sub { sprintf( '%2d', $_[0]->day_of_month ) },
1045 'F' => sub { $_[0]->ymd('-') },
1046 'g' => sub { substr( $_[0]->week_year, -2 ) },
1047 'G' => sub { $_[0]->week_year },
1048 'H' => sub { sprintf( '%02d', $_[0]->hour ) },
1049 'I' => sub { sprintf( '%02d', $_[0]->hour_12 ) },
1050 'j' => sub { sprintf( '%03d', $_[0]->day_of_year ) },
1051 'k' => sub { sprintf( '%2d', $_[0]->hour ) },
1052 'l' => sub { sprintf( '%2d', $_[0]->hour_12 ) },
1053 'm' => sub { sprintf( '%02d', $_[0]->month ) },
1054 'M' => sub { sprintf( '%02d', $_[0]->minute ) },
1055 'n' => sub {"\n"}, # should this be OS-sensitive?
1056 'N' => \&_format_nanosecs,
1057 'p' => sub { $_[0]->am_or_pm() },
1058 'P' => sub { lc $_[0]->am_or_pm() },
1059 'r' => sub { $_[0]->strftime('%I:%M:%S %p') },
1060 'R' => sub { $_[0]->strftime('%H:%M') },
1061 's' => sub { $_[0]->epoch },
1062 'S' => sub { sprintf( '%02d', $_[0]->second ) },
1063 't' => sub {"\t"},
1064 'T' => sub { $_[0]->strftime('%H:%M:%S') },
1065 'u' => sub { $_[0]->day_of_week },
1066 'U' => sub {
1067 my $sun = $_[0]->day_of_year - ( $_[0]->day_of_week + 7 ) % 7;
1068 return sprintf( '%02d', int( ( $sun + 6 ) / 7 ) );
1069 },
1070 'V' => sub { sprintf( '%02d', $_[0]->week_number ) },
1071 'w' => sub {
1072 my $dow = $_[0]->day_of_week;
1073 return $dow % 7;
1074 },
1075 'W' => sub {
1076 my $mon = $_[0]->day_of_year - ( $_[0]->day_of_week + 6 ) % 7;
1077 return sprintf( '%02d', int( ( $mon + 6 ) / 7 ) );
1078 },
1079 'x' => sub {
1080 $_[0]->format_cldr( $_[0]->{locale}->date_format_default() );
1081 },
1082 'X' => sub {
1083 $_[0]->format_cldr( $_[0]->{locale}->time_format_default() );
1084 },
1085 'y' => sub { sprintf( '%02d', substr( $_[0]->year, -2 ) ) },
1086 'Y' => sub { return $_[0]->year },
1087 'z' => sub { DateTime::TimeZone->offset_as_string( $_[0]->offset ) },
1088 'Z' => sub { $_[0]->{tz}->short_name_for_datetime( $_[0] ) },
1089 '%' => sub {'%'},
1090151µs );
1091
109211µs $strftime_patterns{h} = $strftime_patterns{b};
1093
1094 sub strftime {
1095 my $self = shift;
1096
1097 # make a copy or caller's scalars get munged
1098 my @patterns = @_;
1099
1100 my @r;
1101 foreach my $p (@patterns) {
1102 $p =~ s/
1103 ( $1
1104 ? ( $self->can($1) ? $self->$1() : "\%{$1}" )
1105 : $2
1106 ? ( $strftime_patterns{$2} ? $strftime_patterns{$2}->($self) : "\%$2" )
1107 : $3
1108 ? $strftime_patterns{N}->($self, $3)
1109 : '' # this won't happen
1110 )
1111 /sgex;
1112
- -
1121 return $p unless wantarray;
1122
1123 push @r, $p;
1124 }
1125
1126 return @r;
1127 }
1128}
1129
1130{
1131
1132 # It's an array because the order in which the regexes are checked
1133 # is important. These patterns are similar to the ones Java uses,
1134 # but not quite the same. See
1135 # http://www.unicode.org/reports/tr35/tr35-9.html#Date_Format_Patterns.
11361200ns my @patterns = (
1137 qr/GGGGG/ =>
1138 sub { $_[0]->{locale}->era_narrow->[ $_[0]->_era_index() ] },
1139 qr/GGGG/ => 'era_name',
1140 qr/G{1,3}/ => 'era_abbr',
1141
1142 qr/(y{3,5})/ =>
1143 sub { $_[0]->_zero_padded_number( $1, $_[0]->year() ) },
1144
1145 # yy is a weird special case, where it must be exactly 2 digits
1146 qr/yy/ => sub {
1147 my $year = $_[0]->year();
1148 my $y2 = substr( $year, -2, 2 ) if length $year > 2;
1149 $y2 *= -1 if $year < 0;
1150 $_[0]->_zero_padded_number( 'yy', $y2 );
1151 },
1152 qr/y/ => sub { $_[0]->year() },
1153 qr/(u+)/ => sub { $_[0]->_zero_padded_number( $1, $_[0]->year() ) },
1154 qr/(Y+)/ =>
1155 sub { $_[0]->_zero_padded_number( $1, $_[0]->week_year() ) },
1156
1157 qr/QQQQ/ => 'quarter_name',
1158 qr/QQQ/ => 'quarter_abbr',
1159 qr/(QQ?)/ =>
1160 sub { $_[0]->_zero_padded_number( $1, $_[0]->quarter() ) },
1161
1162 qr/qqqq/ => sub {
1163 $_[0]->{locale}->quarter_stand_alone_wide()
1164 ->[ $_[0]->quarter_0() ];
1165 },
1166 qr/qqq/ => sub {
1167 $_[0]->{locale}->quarter_stand_alone_abbreviated()
1168 ->[ $_[0]->quarter_0() ];
1169 },
1170 qr/(qq?)/ =>
1171 sub { $_[0]->_zero_padded_number( $1, $_[0]->quarter() ) },
1172
1173 qr/MMMMM/ =>
1174 sub { $_[0]->{locale}->month_format_narrow->[ $_[0]->month_0() ] }
1175 ,
1176 qr/MMMM/ => 'month_name',
1177 qr/MMM/ => 'month_abbr',
1178 qr/(MM?)/ => sub { $_[0]->_zero_padded_number( $1, $_[0]->month() ) },
1179
1180 qr/LLLLL/ => sub {
1181 $_[0]->{locale}->month_stand_alone_narrow->[ $_[0]->month_0() ];
1182 },
1183 qr/LLLL/ => sub {
1184 $_[0]->{locale}->month_stand_alone_wide->[ $_[0]->month_0() ];
1185 },
1186 qr/LLL/ => sub {
1187 $_[0]->{locale}
1188 ->month_stand_alone_abbreviated->[ $_[0]->month_0() ];
1189 },
1190 qr/(LL?)/ => sub { $_[0]->_zero_padded_number( $1, $_[0]->month() ) },
1191
1192 qr/(ww?)/ =>
1193 sub { $_[0]->_zero_padded_number( $1, $_[0]->week_number() ) },
1194 qr/W/ => 'week_of_month',
1195
1196 qr/(dd?)/ =>
1197 sub { $_[0]->_zero_padded_number( $1, $_[0]->day_of_month() ) },
1198 qr/(D{1,3})/ =>
1199 sub { $_[0]->_zero_padded_number( $1, $_[0]->day_of_year() ) },
1200
1201 qr/F/ => 'weekday_of_month',
1202 qr/(g+)/ => sub { $_[0]->_zero_padded_number( $1, $_[0]->mjd() ) },
1203
1204 qr/EEEEE/ => sub {
1205 $_[0]->{locale}->day_format_narrow->[ $_[0]->day_of_week_0() ];
1206 },
1207 qr/EEEE/ => 'day_name',
1208 qr/E{1,3}/ => 'day_abbr',
1209
1210 qr/eeeee/ => sub {
1211 $_[0]->{locale}->day_format_narrow->[ $_[0]->day_of_week_0() ];
1212 },
1213 qr/eeee/ => 'day_name',
1214 qr/eee/ => 'day_abbr',
1215 qr/(ee?)/ => sub {
1216 $_[0]->_zero_padded_number( $1, $_[0]->local_day_of_week() );
1217 },
1218
1219 qr/ccccc/ => sub {
1220 $_[0]->{locale}
1221 ->day_stand_alone_narrow->[ $_[0]->day_of_week_0() ];
1222 },
1223 qr/cccc/ => sub {
1224 $_[0]->{locale}->day_stand_alone_wide->[ $_[0]->day_of_week_0() ];
1225 },
1226 qr/ccc/ => sub {
1227 $_[0]->{locale}
1228 ->day_stand_alone_abbreviated->[ $_[0]->day_of_week_0() ];
1229 },
1230 qr/(cc?)/ =>
1231 sub { $_[0]->_zero_padded_number( $1, $_[0]->day_of_week() ) },
1232
1233 qr/a/ => 'am_or_pm',
1234
1235 qr/(hh?)/ =>
1236 sub { $_[0]->_zero_padded_number( $1, $_[0]->hour_12() ) },
1237 qr/(HH?)/ => sub { $_[0]->_zero_padded_number( $1, $_[0]->hour() ) },
1238 qr/(KK?)/ =>
1239 sub { $_[0]->_zero_padded_number( $1, $_[0]->hour_12_0() ) },
1240 qr/(kk?)/ =>
1241 sub { $_[0]->_zero_padded_number( $1, $_[0]->hour_1() ) },
1242 qr/(jj?)/ => sub {
1243 my $h
1244 = $_[0]->{locale}->prefers_24_hour_time()
1245 ? $_[0]->hour()
1246 : $_[0]->hour_12();
1247 $_[0]->_zero_padded_number( $1, $h );
1248 },
1249
1250 qr/(mm?)/ =>
1251 sub { $_[0]->_zero_padded_number( $1, $_[0]->minute() ) },
1252
1253 qr/(ss?)/ =>
1254 sub { $_[0]->_zero_padded_number( $1, $_[0]->second() ) },
1255
1256 # I'm not sure this is what is wanted (notably the trailing
1257 # and leading zeros it can produce), but once again the LDML
1258 # spec is not all that clear.
1259 qr/(S+)/ => sub {
1260 my $l = length $1;
1261 my $val = sprintf(
1262 "%.${l}f",
1263 $_[0]->fractional_second() - $_[0]->second()
1264 );
1265 $val =~ s/^0\.//;
1266 $val || 0;
1267 },
1268 qr/A+/ =>
1269 sub { ( $_[0]->{local_rd_secs} * 1000 ) + $_[0]->millisecond() },
1270
1271 qr/zzzz/ => sub { $_[0]->time_zone_long_name() },
1272 qr/z{1,3}/ => sub { $_[0]->time_zone_short_name() },
1273 qr/ZZZZZ/ => sub {
1274 substr(
1275 my $z
1276 = DateTime::TimeZone->offset_as_string( $_[0]->offset() ),
1277 -2, 0, ':'
1278 );
1279 $z;
1280 },
1281 qr/ZZZZ/ => sub {
1282 $_[0]->time_zone_short_name()
1283 . DateTime::TimeZone->offset_as_string( $_[0]->offset() );
1284 },
1285 qr/Z{1,3}/ =>
1286 sub { DateTime::TimeZone->offset_as_string( $_[0]->offset() ) },
1287 qr/vvvv/ => sub { $_[0]->time_zone_long_name() },
1288 qr/v{1,3}/ => sub { $_[0]->time_zone_short_name() },
1289 qr/VVVV/ => sub { $_[0]->time_zone_long_name() },
1290 qr/V{1,3}/ => sub { $_[0]->time_zone_short_name() },
12911165µs5844µs );
# spent 44µs making 58 calls to DateTime::CORE:qr, avg 755ns/call
1292
1293 sub _zero_padded_number {
1294 my $self = shift;
1295 my $size = length shift;
1296 my $val = shift;
1297
1298 return sprintf( "%0${size}d", $val );
1299 }
1300
1301 sub _space_padded_string {
1302 my $self = shift;
1303 my $size = length shift;
1304 my $val = shift;
1305
1306 return sprintf( "% ${size}s", $val );
1307 }
1308
1309 sub format_cldr {
1310 my $self = shift;
1311
1312 # make a copy or caller's scalars get munged
1313 my @patterns = @_;
1314
1315 my @r;
1316 foreach my $p (@patterns) {
1317 $p =~ s/\G
1318 defined $1
1319 ? $1
1320 : defined $2
1321 ? $self->_cldr_pattern($2)
1322 : defined $4
1323 ? $4
1324 : undef # should never get here
1325 /sgex;
1326 (.) # anything else
1327 )
1328 /
1329
- -
1338 $p =~ s/\'\'/\'/g;
1339
1340 return $p unless wantarray;
1341
1342 push @r, $p;
1343 }
1344
1345 return @r;
1346 }
1347
1348 sub _cldr_pattern {
1349 my $self = shift;
1350 my $pattern = shift;
1351
1352 for ( my $i = 0; $i < @patterns; $i += 2 ) {
1353 if ( $pattern =~ /$patterns[$i]/ ) {
1354 my $sub = $patterns[ $i + 1 ];
1355
1356 return $self->$sub();
1357 }
1358 }
1359
1360 return $pattern;
1361 }
1362}
1363
136412µssub _format_nanosecs {
1365 my $self = shift;
1366 my $precision = @_ ? shift : 9;
1367
1368 my $divide_by = 10**( 9 - $precision );
1369
1370 return sprintf(
1371 '%0' . $precision . 'u',
1372 floor( $self->{rd_nanosecs} / $divide_by )
1373 );
1374}
1375
1376sub epoch {
1377 my $self = shift;
1378
1379 return $self->{utc_c}{epoch}
1380 if exists $self->{utc_c}{epoch};
1381
1382 return $self->{utc_c}{epoch}
1383 = ( $self->{utc_rd_days} - 719163 ) * SECONDS_PER_DAY
1384 + $self->{utc_rd_secs};
1385}
1386
1387sub hires_epoch {
1388 my $self = shift;
1389
1390 my $epoch = $self->epoch;
1391
1392 return undef unless defined $epoch;
1393
1394 my $nano = $self->{rd_nanosecs} / MAX_NANOSECONDS;
1395
1396 return $epoch + $nano;
1397}
1398
1399sub is_finite {1}
1400sub is_infinite {0}
1401
1402# added for benefit of DateTime::TimeZone
1403sub utc_year { $_[0]->{utc_year} }
1404
1405# returns a result that is relative to the first datetime
1406sub subtract_datetime {
1407 my $dt1 = shift;
1408 my $dt2 = shift;
1409
1410 $dt2 = $dt2->clone->set_time_zone( $dt1->time_zone )
1411 unless $dt1->time_zone eq $dt2->time_zone;
1412
1413 # We only want a negative duration if $dt2 > $dt1 ($self)
1414 my ( $bigger, $smaller, $negative ) = (
1415 $dt1 >= $dt2
1416 ? ( $dt1, $dt2, 0 )
1417 : ( $dt2, $dt1, 1 )
1418 );
1419
1420 my $is_floating = $dt1->time_zone->is_floating
1421 && $dt2->time_zone->is_floating;
1422
1423 my $minute_length = 60;
1424 unless ($is_floating) {
1425 my ( $utc_rd_days, $utc_rd_secs ) = $smaller->utc_rd_values;
1426
1427 if ( $utc_rd_secs >= 86340 && !$is_floating ) {
1428
1429 # If the smaller of the two datetimes occurs in the last
1430 # UTC minute of the UTC day, then that minute may not be
1431 # 60 seconds long. If we need to subtract a minute from
1432 # the larger datetime's minutes count in order to adjust
1433 # the seconds difference to be positive, we need to know
1434 # how long that minute was. If one of the datetimes is
1435 # floating, we just assume a minute is 60 seconds.
1436
1437 $minute_length = $dt1->_day_length($utc_rd_days) - 86340;
1438 }
1439 }
1440
1441 # This is a gross hack that basically figures out if the bigger of
1442 # the two datetimes is the day of a DST change. If it's a 23 hour
1443 # day (switching _to_ DST) then we subtract 60 minutes from the
1444 # local time. If it's a 25 hour day then we add 60 minutes to the
1445 # local time.
1446 #
1447 # This produces the most "intuitive" results, though there are
1448 # still reversibility problems with the resultant duration.
1449 #
1450 # However, if the two objects are on the same (local) date, and we
1451 # are not crossing a DST change, we don't want to invoke the hack
1452 # - see 38local-subtract.t
1453 my $bigger_min = $bigger->hour * 60 + $bigger->minute;
1454 if ( $bigger->time_zone->has_dst_changes
1455 && $bigger->is_dst != $smaller->is_dst ) {
1456
1457 $bigger_min -= 60
1458
1459 # it's a 23 hour (local) day
1460 if (
1461 $bigger->is_dst
1462 && do {
1463 my $prev_day = try { $bigger->clone->subtract( days => 1 ) };
1464 $prev_day && !$prev_day->is_dst ? 1 : 0;
1465 }
1466 );
1467
1468 $bigger_min += 60
1469
1470 # it's a 25 hour (local) day
1471 if (
1472 !$bigger->is_dst
1473 && do {
1474 my $prev_day = try { $bigger->clone->subtract( days => 1 ) };
1475 $prev_day && $prev_day->is_dst ? 1 : 0;
1476 }
1477 );
1478 }
1479
1480 my ( $months, $days, $minutes, $seconds, $nanoseconds )
1481 = $dt1->_adjust_for_positive_difference(
1482 $bigger->year * 12 + $bigger->month,
1483 $smaller->year * 12 + $smaller->month,
1484
1485 $bigger->day, $smaller->day,
1486
1487 $bigger_min, $smaller->hour * 60 + $smaller->minute,
1488
1489 $bigger->second, $smaller->second,
1490
1491 $bigger->nanosecond, $smaller->nanosecond,
1492
1493 $minute_length,
1494
1495 # XXX - using the smaller as the month length is
1496 # somewhat arbitrary, we could also use the bigger -
1497 # either way we have reversibility problems
1498 $dt1->_month_length( $smaller->year, $smaller->month ),
1499 );
1500
1501 if ($negative) {
1502 for ( $months, $days, $minutes, $seconds, $nanoseconds ) {
1503
1504 # Some versions of Perl can end up with -0 if we do "0 * -1"!!
1505 $_ *= -1 if $_;
1506 }
1507 }
1508
1509 return $dt1->duration_class->new(
1510 months => $months,
1511 days => $days,
1512 minutes => $minutes,
1513 seconds => $seconds,
1514 nanoseconds => $nanoseconds,
1515 );
1516}
1517
1518sub _adjust_for_positive_difference {
1519 my (
1520 $self,
1521 $month1, $month2,
1522 $day1, $day2,
1523 $min1, $min2,
1524 $sec1, $sec2,
1525 $nano1, $nano2,
1526 $minute_length,
1527 $month_length,
1528 ) = @_;
1529
1530 if ( $nano1 < $nano2 ) {
1531 $sec1--;
1532 $nano1 += MAX_NANOSECONDS;
1533 }
1534
1535 if ( $sec1 < $sec2 ) {
1536 $min1--;
1537 $sec1 += $minute_length;
1538 }
1539
1540 # A day always has 24 * 60 minutes, though the minutes may vary in
1541 # length.
1542 if ( $min1 < $min2 ) {
1543 $day1--;
1544 $min1 += 24 * 60;
1545 }
1546
1547 if ( $day1 < $day2 ) {
1548 $month1--;
1549 $day1 += $month_length;
1550 }
1551
1552 return (
1553 $month1 - $month2,
1554 $day1 - $day2,
1555 $min1 - $min2,
1556 $sec1 - $sec2,
1557 $nano1 - $nano2,
1558 );
1559}
1560
1561sub subtract_datetime_absolute {
1562 my $self = shift;
1563 my $dt = shift;
1564
1565 my $utc_rd_secs1 = $self->utc_rd_as_seconds;
1566 $utc_rd_secs1
1567 += DateTime->_accumulated_leap_seconds( $self->{utc_rd_days} )
1568 if !$self->time_zone->is_floating;
1569
1570 my $utc_rd_secs2 = $dt->utc_rd_as_seconds;
1571 $utc_rd_secs2 += DateTime->_accumulated_leap_seconds( $dt->{utc_rd_days} )
1572 if !$dt->time_zone->is_floating;
1573
1574 my $seconds = $utc_rd_secs1 - $utc_rd_secs2;
1575 my $nanoseconds = $self->nanosecond - $dt->nanosecond;
1576
1577 if ( $nanoseconds < 0 ) {
1578 $seconds--;
1579 $nanoseconds += MAX_NANOSECONDS;
1580 }
1581
1582 return $self->duration_class->new(
1583 seconds => $seconds,
1584 nanoseconds => $nanoseconds,
1585 );
1586}
1587
1588sub delta_md {
1589 my $self = shift;
1590 my $dt = shift;
1591
1592 my ( $smaller, $bigger ) = sort $self, $dt;
1593
1594 my ( $months, $days, undef, undef, undef )
1595 = $dt->_adjust_for_positive_difference(
1596 $bigger->year * 12 + $bigger->month,
1597 $smaller->year * 12 + $smaller->month,
1598
1599 $bigger->day, $smaller->day,
1600
1601 0, 0,
1602
1603 0, 0,
1604
1605 0, 0,
1606
1607 60,
1608
1609 $smaller->_month_length( $smaller->year, $smaller->month ),
1610 );
1611
1612 return $self->duration_class->new(
1613 months => $months,
1614 days => $days
1615 );
1616}
1617
1618sub delta_days {
1619 my $self = shift;
1620 my $dt = shift;
1621
1622 my $days
1623 = abs( ( $self->local_rd_values )[0] - ( $dt->local_rd_values )[0] );
1624
1625 $self->duration_class->new( days => $days );
1626}
1627
1628sub delta_ms {
1629 my $self = shift;
1630 my $dt = shift;
1631
1632 my ( $smaller, $greater ) = sort $self, $dt;
1633
1634 my $days = int( $greater->jd - $smaller->jd );
1635
1636 my $dur = $greater->subtract_datetime($smaller);
1637
1638 my %p;
1639 $p{hours} = $dur->hours + ( $days * 24 );
1640 $p{minutes} = $dur->minutes;
1641 $p{seconds} = $dur->seconds;
1642
1643 return $self->duration_class->new(%p);
1644}
1645
1646sub _add_overload {
1647 my ( $dt, $dur, $reversed ) = @_;
1648
1649 if ($reversed) {
1650 ( $dur, $dt ) = ( $dt, $dur );
1651 }
1652
1653 unless ( DateTime::Helpers::isa( $dur, 'DateTime::Duration' ) ) {
1654 my $class = ref $dt;
1655 my $dt_string = overload::StrVal($dt);
1656
1657 Carp::croak( "Cannot add $dur to a $class object ($dt_string).\n"
1658 . ' Only a DateTime::Duration object can '
1659 . " be added to a $class object." );
1660 }
1661
1662 return $dt->clone->add_duration($dur);
1663}
1664
1665sub _subtract_overload {
1666 my ( $date1, $date2, $reversed ) = @_;
1667
1668 if ($reversed) {
1669 ( $date2, $date1 ) = ( $date1, $date2 );
1670 }
1671
1672 if ( DateTime::Helpers::isa( $date2, 'DateTime::Duration' ) ) {
1673 my $new = $date1->clone;
1674 $new->add_duration( $date2->inverse );
1675 return $new;
1676 }
1677 elsif ( DateTime::Helpers::isa( $date2, 'DateTime' ) ) {
1678 return $date1->subtract_datetime($date2);
1679 }
1680 else {
1681 my $class = ref $date1;
1682 my $dt_string = overload::StrVal($date1);
1683
1684 Carp::croak(
1685 "Cannot subtract $date2 from a $class object ($dt_string).\n"
1686 . ' Only a DateTime::Duration or DateTime object can '
1687 . " be subtracted from a $class object." );
1688 }
1689}
1690
1691sub add {
1692 my $self = shift;
1693
1694 return $self->add_duration( $self->duration_class->new(@_) );
1695}
1696
1697sub subtract {
1698 my $self = shift;
1699 my %p = @_;
1700
1701 my %eom;
1702 $eom{end_of_month} = delete $p{end_of_month}
1703 if exists $p{end_of_month};
1704
1705 my $dur = $self->duration_class->new(@_)->inverse(%eom);
1706
1707 return $self->add_duration($dur);
1708}
1709
1710sub subtract_duration { return $_[0]->add_duration( $_[1]->inverse ) }
1711
1712{
171312µs my @spec = ( { isa => 'DateTime::Duration' } );
1714
1715 sub add_duration {
1716 my $self = shift;
1717 my ($dur) = validate_pos( @_, @spec );
1718
1719 # simple optimization
1720 return $self if $dur->is_zero;
1721
1722 my %deltas = $dur->deltas;
1723
1724 # This bit isn't quite right since DateTime::Infinite::Future -
1725 # infinite duration should NaN
1726 foreach my $val ( values %deltas ) {
1727 my $inf;
1728 if ( $val == INFINITY ) {
1729 $inf = DateTime::Infinite::Future->new;
1730 }
1731 elsif ( $val == NEG_INFINITY ) {
1732 $inf = DateTime::Infinite::Past->new;
1733 }
1734
1735 if ($inf) {
1736 %$self = %$inf;
1737 bless $self, ref $inf;
1738
1739 return $self;
1740 }
1741 }
1742
1743 return $self if $self->is_infinite;
1744
1745 if ( $deltas{days} ) {
1746 $self->{local_rd_days} += $deltas{days};
1747
1748 $self->{utc_year} += int( $deltas{days} / 365 ) + 1;
1749 }
1750
1751 if ( $deltas{months} ) {
1752
1753 # For preserve mode, if it is the last day of the month, make
1754 # it the 0th day of the following month (which then will
1755 # normalize back to the last day of the new month).
1756 my ( $y, $m, $d ) = (
1757 $dur->is_preserve_mode
1758 ? $self->_rd2ymd( $self->{local_rd_days} + 1 )
1759 : $self->_rd2ymd( $self->{local_rd_days} )
1760 );
1761
1762 $d -= 1 if $dur->is_preserve_mode;
1763
1764 if ( !$dur->is_wrap_mode && $d > 28 ) {
1765
1766 # find the rd for the last day of our target month
1767 $self->{local_rd_days}
1768 = $self->_ymd2rd( $y, $m + $deltas{months} + 1, 0 );
1769
1770 # what day of the month is it? (discard year and month)
1771 my $last_day
1772 = ( $self->_rd2ymd( $self->{local_rd_days} ) )[2];
1773
1774 # if our original day was less than the last day,
1775 # use that instead
1776 $self->{local_rd_days} -= $last_day - $d if $last_day > $d;
1777 }
1778 else {
1779 $self->{local_rd_days}
1780 = $self->_ymd2rd( $y, $m + $deltas{months}, $d );
1781 }
1782
1783 $self->{utc_year} += int( $deltas{months} / 12 ) + 1;
1784 }
1785
1786 if ( $deltas{days} || $deltas{months} ) {
1787 $self->_calc_utc_rd;
1788
1789 $self->_handle_offset_modifier( $self->second );
1790 }
1791
1792 if ( $deltas{minutes} ) {
1793 $self->{utc_rd_secs} += $deltas{minutes} * 60;
1794
1795 # This intentionally ignores leap seconds
1796 $self->_normalize_tai_seconds(
1797 $self->{utc_rd_days},
1798 $self->{utc_rd_secs}
1799 );
1800 }
1801
1802 if ( $deltas{seconds} || $deltas{nanoseconds} ) {
1803 $self->{utc_rd_secs} += $deltas{seconds};
1804
1805 if ( $deltas{nanoseconds} ) {
1806 $self->{rd_nanosecs} += $deltas{nanoseconds};
1807 $self->_normalize_nanoseconds(
1808 $self->{utc_rd_secs},
1809 $self->{rd_nanosecs}
1810 );
1811 }
1812
1813 $self->_normalize_seconds;
1814
1815 # This might be some big number much bigger than 60, but
1816 # that's ok (there are tests in 19leap_second.t to confirm
1817 # that)
1818 $self->_handle_offset_modifier(
1819 $self->second + $deltas{seconds} );
1820 }
1821
1822 my $new = ( ref $self )->from_object(
1823 object => $self,
1824 locale => $self->{locale},
1825 ( $self->{formatter} ? ( formatter => $self->{formatter} ) : () ),
1826 );
1827
1828 %$self = %$new;
1829
1830 return $self;
1831 }
1832}
1833
18341400nssub _compare_overload {
1835
1836 # note: $_[1]->compare( $_[0] ) is an error when $_[1] is not a
1837 # DateTime (such as the INFINITY value)
1838
1839 return undef unless defined $_[1];
1840
1841 return $_[2] ? -$_[0]->compare( $_[1] ) : $_[0]->compare( $_[1] );
1842}
1843
1844sub _string_compare_overload {
1845 my ( $dt1, $dt2, $flip ) = @_;
1846
1847 # One is a DateTime object, one isn't. Just stringify and compare.
1848 if ( !DateTime::Helpers::can( $dt2, 'utc_rd_values' ) ) {
1849 my $sign = $flip ? -1 : 1;
1850 return $sign * ( "$dt1" cmp "$dt2" );
1851 }
1852 else {
1853 my $meth = $dt1->can('_compare_overload');
1854 goto $meth;
1855 }
1856}
1857
1858sub compare {
1859 shift->_compare( @_, 0 );
1860}
1861
1862sub compare_ignore_floating {
1863 shift->_compare( @_, 1 );
1864}
1865
1866sub _compare {
1867 my ( $class, $dt1, $dt2, $consistent ) = ref $_[0] ? ( undef, @_ ) : @_;
1868
1869 return undef unless defined $dt2;
1870
1871 if ( !ref $dt2 && ( $dt2 == INFINITY || $dt2 == NEG_INFINITY ) ) {
1872 return $dt1->{utc_rd_days} <=> $dt2;
1873 }
1874
1875 unless ( DateTime::Helpers::can( $dt1, 'utc_rd_values' )
1876 && DateTime::Helpers::can( $dt2, 'utc_rd_values' ) ) {
1877 my $dt1_string = overload::StrVal($dt1);
1878 my $dt2_string = overload::StrVal($dt2);
1879
1880 Carp::croak( 'A DateTime object can only be compared to'
1881 . " another DateTime object ($dt1_string, $dt2_string)." );
1882 }
1883
1884 if ( !$consistent
1885 && DateTime::Helpers::can( $dt1, 'time_zone' )
1886 && DateTime::Helpers::can( $dt2, 'time_zone' ) ) {
1887 my $is_floating1 = $dt1->time_zone->is_floating;
1888 my $is_floating2 = $dt2->time_zone->is_floating;
1889
1890 if ( $is_floating1 && !$is_floating2 ) {
1891 $dt1 = $dt1->clone->set_time_zone( $dt2->time_zone );
1892 }
1893 elsif ( $is_floating2 && !$is_floating1 ) {
1894 $dt2 = $dt2->clone->set_time_zone( $dt1->time_zone );
1895 }
1896 }
1897
1898 my @dt1_components = $dt1->utc_rd_values;
1899 my @dt2_components = $dt2->utc_rd_values;
1900
1901 foreach my $i ( 0 .. 2 ) {
1902 return $dt1_components[$i] <=> $dt2_components[$i]
1903 if $dt1_components[$i] != $dt2_components[$i];
1904 }
1905
1906 return 0;
1907}
1908
1909sub _string_equals_overload {
1910 my ( $class, $dt1, $dt2 ) = ref $_[0] ? ( undef, @_ ) : @_;
1911
1912 if ( !DateTime::Helpers::can( $dt2, 'utc_rd_values' ) ) {
1913 return "$dt1" eq "$dt2";
1914 }
1915
1916 $class ||= ref $dt1;
1917 return !$class->compare( $dt1, $dt2 );
1918}
1919
1920sub _string_not_equals_overload {
1921 return !_string_equals_overload(@_);
1922}
1923
1924
# spent 9.87ms within DateTime::_normalize_nanoseconds which was called 13000 times, avg 760ns/call: # 13000 times (9.87ms+0s) by DateTime::_new at line 250, avg 760ns/call
sub _normalize_nanoseconds {
192521.07ms215µs
# spent 12µs (10+2) within DateTime::BEGIN@1925 which was called: # once (10µs+2µs) by DateTime::Format::Alami::parse_datetime at line 1925
use integer;
# spent 12µs making 1 call to DateTime::BEGIN@1925 # spent 2µs making 1 call to integer::import
1926
1927 # seconds, nanoseconds
19281300036.1ms if ( $_[2] < 0 ) {
1929 my $overflow = 1 + $_[2] / MAX_NANOSECONDS;
1930 $_[2] += $overflow * MAX_NANOSECONDS;
1931 $_[1] -= $overflow;
1932 }
1933 elsif ( $_[2] >= MAX_NANOSECONDS ) {
1934 my $overflow = $_[2] / MAX_NANOSECONDS;
1935 $_[2] -= $overflow * MAX_NANOSECONDS;
1936 $_[1] += $overflow;
1937 }
1938}
1939
1940# Many of the same parameters as new() but all of them are optional,
1941# and there are no defaults.
1942my $SetValidate = {
1943 map {
19441115µs my %copy = %{ $BasicValidate->{$_} };
1945101µs delete $copy{default};
1946102µs $copy{optional} = 1;
1947102µs $_ => \%copy
1948 }
1949 keys %$BasicValidate
1950};
1951
1952
# spent 1.37s (83.3ms+1.29) within DateTime::set which was called 6000 times, avg 229µs/call: # 3000 times (45.4ms+645ms) by DateTime::set_day at line 1965, avg 230µs/call # 3000 times (37.9ms+644ms) by DateTime::set_month at line 1964, avg 227µs/call
sub set {
19536000958µs my $self = shift;
1954600097.0ms12000151ms my %p = validate( @_, $SetValidate );
# spent 122ms making 6000 calls to Params::Validate::XS::validate, avg 20µs/call # spent 16.4ms making 3000 calls to DateTime::__ANON__[DateTime.pm:135], avg 5µs/call # spent 12.4ms making 3000 calls to DateTime::__ANON__[DateTime.pm:127], avg 4µs/call
1955
195660009.93ms60001.17s my $new_dt = $self->_new_from_self(%p);
# spent 1.17s making 6000 calls to DateTime::_new_from_self, avg 195µs/call
1957
1958600030.0ms %$self = %$new_dt;
1959
1960600017.1ms return $self;
1961}
1962
1963sub set_year { $_[0]->set( year => $_[1] ) }
196430005.11ms3000682ms
# spent 691ms (9.73+682) within DateTime::set_month which was called 3000 times, avg 230µs/call: # 3000 times (9.73ms+682ms) by DateTime::Format::Alami::a_dateymd at line 499 of lib/DateTime/Format/Alami.pm, avg 230µs/call
sub set_month { $_[0]->set( month => $_[1] ) }
# spent 682ms making 3000 calls to DateTime::set, avg 227µs/call
196530005.24ms3000691ms
# spent 698ms (6.93+691) within DateTime::set_day which was called 3000 times, avg 233µs/call: # 3000 times (6.93ms+691ms) by DateTime::Format::Alami::a_dateymd at line 490 of lib/DateTime/Format/Alami.pm, avg 233µs/call
sub set_day { $_[0]->set( day => $_[1] ) }
# spent 691ms making 3000 calls to DateTime::set, avg 230µs/call
1966sub set_hour { $_[0]->set( hour => $_[1] ) }
1967sub set_minute { $_[0]->set( minute => $_[1] ) }
1968sub set_second { $_[0]->set( second => $_[1] ) }
1969sub set_nanosecond { $_[0]->set( nanosecond => $_[1] ) }
1970
1971# These two are special cased because ... if the local time is the hour of a
1972# DST change where the same local time occurs twice then passing it through
1973# _new() can actually change the underlying UTC time, which is bad.
1974
1975sub set_locale {
1976 my $self = shift;
1977
1978 my ($locale) = validate_pos( @_, $BasicValidate->{locale} );
1979
1980 $self->_set_locale($locale);
1981
1982 return $self;
1983}
1984
1985sub set_formatter {
1986 my $self = shift;
1987 my ($formatter) = validate_pos( @_, $BasicValidate->{formatter} );
1988
1989 $self->{formatter} = $formatter;
1990
1991 return $self;
1992}
1993
1994{
199512µs my %TruncateDefault = (
1996 month => 1,
1997 day => 1,
1998 hour => 0,
1999 minute => 0,
2000 second => 0,
2001 nanosecond => 0,
2002 );
2003 my $re = join '|', 'year', 'week', 'local_week',
200414µs grep { $_ ne 'nanosecond' } keys %TruncateDefault;
2005133µs225µs my $spec = { to => { regex => qr/^(?:$re)$/ } };
# spent 24µs making 1 call to DateTime::CORE:regcomp # spent 800ns making 1 call to DateTime::CORE:qr
2006
2007
# spent 593ms (114+479) within DateTime::truncate which was called 4000 times, avg 148µs/call: # 3000 times (81.5ms+358ms) by DateTime::today at line 573, avg 146µs/call # 1000 times (32.4ms+121ms) by DateTime::Format::Alami::parse_datetime at line 190 of lib/DateTime/Format/Alami.pm, avg 154µs/call
sub truncate {
20084000655µs my $self = shift;
2009400046.7ms800088.1ms my %p = validate( @_, $spec );
# spent 60.7ms making 4000 calls to Params::Validate::XS::validate, avg 15µs/call # spent 27.5ms making 4000 calls to Params::Validate::XS::_check_regex_from_xs, avg 7µs/call
2010
20114000415µs my %new;
201240002.57ms if ( $p{to} eq 'week' || $p{to} eq 'local_week' ) {
2013 my $first_day_of_week
2014 = ( $p{to} eq 'local_week' )
2015 ? $self->{locale}->first_day_of_week
2016 : 1;
2017
2018 my $day_diff = ( $self->day_of_week - $first_day_of_week ) % 7;
2019
2020 if ($day_diff) {
2021 $self->add( days => -1 * $day_diff );
2022 }
2023
2024 # This can fail if the truncate ends up giving us an invalid local
2025 # date time. If that happens we need to reverse the addition we
2026 # just did. See https://rt.cpan.org/Ticket/Display.html?id=93347.
2027 try {
2028 $self->truncate( to => 'day' );
2029 }
2030 catch {
2031 $self->add( days => $day_diff );
2032 die $_;
2033 };
2034 }
2035 else {
20364000376µs my $truncate;
203740002.68ms foreach my $f (qw( year month day hour minute second nanosecond ))
2038 {
20392800019.2ms1200011.2ms $new{$f} = $truncate ? $TruncateDefault{$f} : $self->$f();
# spent 4.40ms making 4000 calls to DateTime::year, avg 1µs/call # spent 3.44ms making 4000 calls to DateTime::month, avg 859ns/call # spent 3.34ms making 4000 calls to DateTime::day_of_month, avg 834ns/call
2040
2041280008.49ms $truncate = 1 if $p{to} eq $f;
2042 }
2043 }
2044
204540008.21ms4000407ms my $new_dt = $self->_new_from_self( %new, _skip_validation => 1 );
# spent 407ms making 4000 calls to DateTime::_new_from_self, avg 102µs/call
2046
2047400020.1ms %$self = %$new_dt;
2048
2049400017.3ms return $self;
2050 }
2051}
2052
205311µssub set_time_zone {
2054 my ( $self, $tz ) = @_;
2055
2056 if ( ref $tz ) {
2057
2058 # This is a bit of a hack but it works because time zone objects
2059 # are singletons, and if it doesn't work all we lose is a little
2060 # bit of speed.
2061 return $self if $self->{tz} eq $tz;
2062 }
2063 else {
2064 return $self if $self->{tz}->name() eq $tz;
2065 }
2066
2067 my $was_floating = $self->{tz}->is_floating;
2068
2069 my $old_tz = $self->{tz};
2070 $self->{tz} = ref $tz ? $tz : DateTime::TimeZone->new( name => $tz );
2071
2072 $self->_handle_offset_modifier( $self->second, 1 );
2073
2074 my $e;
2075 try {
2076 # if it either was or now is floating (but not both)
2077 if ( $self->{tz}->is_floating xor $was_floating ) {
2078 $self->_calc_utc_rd;
2079 }
2080 elsif ( !$was_floating ) {
2081 $self->_calc_local_rd;
2082 }
2083 }
2084 catch {
2085 $e = $_;
2086 };
2087
2088 # If we can't recalc the RD values then we shouldn't keep the new TZ. RT
2089 # #83940
2090 if ($e) {
2091 $self->{tz} = $old_tz;
2092 die $e;
2093 }
2094
2095 return $self;
2096}
2097
2098sub STORABLE_freeze {
2099 my $self = shift;
2100 my $cloning = shift;
2101
2102 my $serialized = '';
2103 foreach my $key (
2104 qw( utc_rd_days
2105 utc_rd_secs
2106 rd_nanosecs )
2107 ) {
2108 $serialized .= "$key:$self->{$key}|";
2109 }
2110
2111 # not used yet, but may be handy in the future.
2112 $serialized .= 'version:' . ( $DateTime::VERSION || 'git' );
2113
2114 # Formatter needs to be returned as a reference since it may be
2115 # undef or a class name, and Storable will complain if extra
2116 # return values aren't refs
2117 return $serialized, $self->{locale}, $self->{tz}, \$self->{formatter};
2118}
2119
2120sub STORABLE_thaw {
2121 my $self = shift;
2122 my $cloning = shift;
2123 my $serialized = shift;
2124
2125 my %serialized = map { split /:/ } split /\|/, $serialized;
2126
2127 my ( $locale, $tz, $formatter );
2128
2129 # more recent code version
2130 if (@_) {
2131 ( $locale, $tz, $formatter ) = @_;
2132 }
2133 else {
2134 $tz = DateTime::TimeZone->new( name => delete $serialized{tz} );
2135
2136 $locale = DateTime::Locale->load(
2137 exists $serialized{language}
2138 ? delete $serialized{language}
2139 : delete $serialized{locale}
2140 );
2141 }
2142
2143 delete $serialized{version};
2144
2145 my $object = bless {
2146 utc_vals => [
2147 $serialized{utc_rd_days},
2148 $serialized{utc_rd_secs},
2149 $serialized{rd_nanosecs},
2150 ],
2151 tz => $tz,
2152 },
2153 'DateTime::_Thawed';
2154
2155 my %formatter = defined $$formatter ? ( formatter => $$formatter ) : ();
2156 my $new = ( ref $self )->from_object(
2157 object => $object,
2158 locale => $locale,
2159 %formatter,
2160 );
2161
2162 %$self = %$new;
2163
2164 return $self;
2165}
2166
2167package # hide from PAUSE
2168 DateTime::_Thawed;
2169
2170sub utc_rd_values { @{ $_[0]->{utc_vals} } }
2171
2172sub time_zone { $_[0]->{tz} }
2173
2174144µs1;
2175
2176# ABSTRACT: A date and time object for Perl
2177
2178__END__
 
# spent 38.9ms within DateTime::CORE:match which was called 51000 times, avg 763ns/call: # 9000 times (7.69ms+0s) by DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:135] at line 135, avg 855ns/call # 9000 times (7.66ms+0s) by DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:127] at line 127, avg 851ns/call # 6000 times (5.48ms+0s) by DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:119] at line 119, avg 913ns/call # 6000 times (4.61ms+0s) by DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:143] at line 143, avg 769ns/call # 6000 times (4.11ms+0s) by DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:151] at line 151, avg 686ns/call # 6000 times (3.91ms+0s) by DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:159] at line 159, avg 651ns/call # 6000 times (3.77ms+0s) by DateTime::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/x86_64-linux/DateTime.pm:166] at line 166, avg 629ns/call # 3000 times (1.70ms+0s) by DateTime::from_epoch at line 517, avg 566ns/call
sub DateTime::CORE:match; # opcode
# spent 47µs within DateTime::CORE:qr which was called 60 times, avg 790ns/call: # 58 times (44µs+0s) by DateTime::Format::Alami::parse_datetime at line 1291, avg 755ns/call # once (3µs+0s) by DateTime::Format::Alami::parse_datetime at line 481 # once (800ns+0s) by DateTime::Format::Alami::parse_datetime at line 2005
sub DateTime::CORE:qr; # opcode
# spent 24µs within DateTime::CORE:regcomp which was called: # once (24µs+0s) by DateTime::Format::Alami::parse_datetime at line 2005
sub DateTime::CORE:regcomp; # opcode
# spent 8.66ms within DateTime::_normalize_tai_seconds which was called 13002 times, avg 666ns/call: # 13002 times (8.66ms+0s) by DateTime::_calc_utc_rd at line 413, avg 666ns/call
sub DateTime::_normalize_tai_seconds; # xsub
# spent 8.17ms within DateTime::_rd2ymd which was called 13000 times, avg 628ns/call: # 13000 times (8.17ms+0s) by DateTime::_calc_local_components at line 471, avg 628ns/call
sub DateTime::_rd2ymd; # xsub
# spent 6.58ms within DateTime::_seconds_as_components which was called 13000 times, avg 506ns/call: # 13000 times (6.58ms+0s) by DateTime::_calc_local_components at line 477, avg 506ns/call
sub DateTime::_seconds_as_components; # xsub
# spent 5.64ms within DateTime::_time_as_seconds which was called 13000 times, avg 434ns/call: # 13000 times (5.64ms+0s) by DateTime::_new at line 240, avg 434ns/call
sub DateTime::_time_as_seconds; # xsub
# spent 8.09ms within DateTime::_ymd2rd which was called 13000 times, avg 623ns/call: # 13000 times (8.09ms+0s) by DateTime::_new at line 237, avg 623ns/call
sub DateTime::_ymd2rd; # xsub