Skip to content

Commit

Permalink
save work
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrowder committed Feb 10, 2024
1 parent 60d343f commit 59d73ab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions META6.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions dev/run.raku
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions lib/DateTime/US.rakumod
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
unit class DateTime::US;

use LocalTime;
use Timezones::US;
use Date::Utils;

Expand Down Expand Up @@ -77,14 +78,16 @@ 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) {
# nth(1) dow(7) in month 11 at 0200 local
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);
}

0 comments on commit 59d73ab

Please sign in to comment.