From 59d73ab8dbadf481da0e9368ef1411dcf137e9d5 Mon Sep 17 00:00:00 2001 From: Tom Browder Date: Fri, 9 Feb 2024 19:21:47 -0600 Subject: [PATCH] save work --- META6.json | 1 + dev/run.raku | 5 +++-- lib/DateTime/US.rakumod | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/META6.json b/META6.json index a7d77f4..dbb3409 100644 --- a/META6.json +++ b/META6.json @@ -7,6 +7,7 @@ ], "depends": [ "Date::Utils", + "LocalTime", "Timezones::US" ], "description": "Provides time zone and Daylight Saving Time (DST) infomation for US states and territories", diff --git a/dev/run.raku b/dev/run.raku index 51394f6..efc0bad 100755 --- a/dev/run.raku +++ b/dev/run.raku @@ -4,9 +4,10 @@ use lib <../lib>; use DateTime::US; my $tz = DateTime::US.new: :timezone('cst'); -dd $tz; -say $tz.begin-dst; +my $year = 2024; +say $tz.dst-begin: :$year; +say $tz.dst-end: :$year; =finish diff --git a/lib/DateTime/US.rakumod b/lib/DateTime/US.rakumod index 18edd11..0cddc33 100644 --- a/lib/DateTime/US.rakumod +++ b/lib/DateTime/US.rakumod @@ -1,5 +1,6 @@ unit class DateTime::US; +use LocalTime; use Timezones::US; use Date::Utils; @@ -77,7 +78,8 @@ multi method dst-begin(:$year! --> DateTime) { my $nth = 2; my $dow = 7; my $month = 3; - nth-dow-in-month :$year, :$month, :$nth; #:nDate.new: :$year, :month(3); + my $date = nth-dow-in-month :$year, :$month, :$nth, :$dow; + DateTime.new: :$year, :$month, :day($date.day), :hour(2); } multi method dst-end(:$year --> DateTime) { @@ -85,6 +87,7 @@ multi method dst-end(:$year --> DateTime) { my $nth = 1; my $dow = 7; my $month = 11; - nth-dow-in-month :$year, :$month, :$nth; #:nDate.new: :$year, :month(3); + my $date = nth-dow-in-month :$year, :$month, :$nth, :$dow; + DateTime.new: :$year, :$month, :day($date.day), :hour(2); }