-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some DateTimes created early (precompilation, etc) may not get created with the wrapped new method. This update catches those when appropriate and upgrades them.
- Loading branch information
1 parent
cbee967
commit 5ed8a83
Showing
8 changed files
with
227 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
use DateTime::Timezones; | ||
sub MAIN (**@timezones) { | ||
sub MAIN (**@timezones where * > 0) { | ||
react whenever Supply.interval(1) { | ||
my $time = DateTime.new: now; | ||
say " {.hh-mm-ss} {.tz-abbr}\t{.olson-id}" | ||
for @timezones.map({$time.in-timezone: $_}); | ||
print "\x001b[F" xx @timezones; | ||
} | ||
} | ||
|
||
sub USAGE { | ||
print q:to/END/ | ||
Usage: raku world-clock.raku Olson/ID Olson/ID … | ||
Each Olson ID should be in the format of Region/City. | ||
Updates with the time for the given zones each second. | ||
END | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use Test; | ||
|
||
# This is about the only way that it's possible for an | ||
# old fashioned DateTime to be made. Each one will be | ||
# tested that it upgrades properly based on its mutability | ||
my $olson1 = BEGIN DateTime.new: now; | ||
my \olson2 = BEGIN DateTime.new: now; | ||
my $abbr1 = BEGIN DateTime.new: now; | ||
my \abbr2 = BEGIN DateTime.new: now; | ||
my $dst1 = BEGIN DateTime.new: now; | ||
my \dst2 = BEGIN DateTime.new: now; | ||
|
||
# All new timezones should be TimezoneAware | ||
use DateTime::Timezones; | ||
|
||
# First check whether mutable containers are correctly upgraded | ||
try { | ||
$olson1.olson-id; | ||
ok $olson1 ~~ Timezones::TimezoneAware, "Mutable upgrade for Olson ID"; | ||
CATCH { ok False, "Mutable upgrade for Olson ID" } | ||
} | ||
try { | ||
$abbr1.tz-abbr; | ||
ok $abbr1 ~~ Timezones::TimezoneAware, "Mutable upgrade for TZ abbreviation"; | ||
CATCH { ok False, "Mutable upgrade for TZ abbreviation" } | ||
} | ||
try { | ||
$dst1.is-dst; | ||
ok $dst1 ~~ Timezones::TimezoneAware, "Mutable upgrade for DST status"; | ||
CATCH { ok False, "Mutable upgrade for DST status" } | ||
} | ||
|
||
# Next, check whether inmutables still provide nominally correct values | ||
try { | ||
olson2.olson-id; | ||
ok olson2.olson-id ~~ Str, "Inmutable upgrade for Olson ID"; | ||
CATCH { ok False, "Inmutable upgrade for Olson ID"} | ||
} | ||
try { | ||
abbr2.tz-abbr; | ||
ok abbr2.tz-abbr ~~ Str, "Mutable upgrade for TZ abbreviation"; | ||
CATCH { ok False, "Inmutable upgrade for TZ abbreviation" } | ||
} | ||
try { | ||
dst2.is-dst; | ||
ok dst2.is-dst ~~ Bool, "Inmutable upgrade for DST status"; | ||
CATCH { ok False, "Inmutable upgrade for DST status" } | ||
} | ||
|
||
done-testing; |