Skip to content

Commit

Permalink
Minor cleanup for compose-time
Browse files Browse the repository at this point in the history
  • Loading branch information
cgay committed Feb 29, 2024
1 parent 72fd9b3 commit ede3841
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sources/time.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,17 @@ define inline function adjust-for-zone-offset
end function;

define method compose-time
(y :: <integer>, mon :: <month>, d :: <integer>, h :: <integer>,
(year :: <integer>, mon :: <month>, day :: <integer>, hour :: <integer>,
min :: <integer>, sec :: <integer>, nano :: <integer>, zone :: <zone>)
=> (_ :: <time>)
let days = days-from-civil(y, month-number(mon), d);
let nanoseconds = (h * 60 * 60_000_000_000
=> (t :: <time>)
let days = days-from-civil(year, month-number(mon), day);
let nanoseconds = (hour * 60 * 60_000_000_000
+ min * 60_000_000_000
+ sec * 1_000_000_000
+ nano);
// TODO: this call to zone-offset-seconds ends up calling time-now(). We shouldn't need
// to allocate an extra <time> to make a <time>. Make a %zone-offset that accepts days
// and nanos and a %time-now that returns them?
// TODO: this call to zone-offset-seconds ends up calling time-now() if `zone` is
// aware. We shouldn't need to allocate an extra <time> to make a <time>. Make a
// %zone-offset that accepts days and nanos and a %time-now that returns them?
let (days, nanos)
= adjust-for-zone-offset(days, nanoseconds,
zone-offset-seconds(zone) * $nanos/second);
Expand Down

0 comments on commit ede3841

Please sign in to comment.