12 Time Arithmetic
procedure
(time-arithmetic-provider? x) → boolean
x : any/c
procedure
(+hours t n) → time-arithmetic-provider
t : time-arithmetic-provider? n : exact-integer?
procedure
(-hours t n) → time-arithmetic-provider?
t : time-arithmetic-provider? n : exact-integer?
> (+hours (time 22) 4) #<time 02:00:00>
> (-hours (datetime 1970) 12) #<datetime 1969-12-31T12:00:00>
> (+hours (moment 2015 3 8 1 #:tz "America/New_York") 1) #<moment 2015-03-08T03:00:00-04:00[America/New_York]>
> (-hours (years 5) 20) #<period of 5 years, -20 hours>
procedure
(+minutes t n) → time-arithmetic-provider?
t : time-arithmetic-provider? n : exact-integer?
procedure
(-minutes t n) → time-arithmetic-provider?
t : time-arithmetic-provider? n : exact-integer?
> (+minutes (time 22) 4) #<time 22:04:00>
> (-minutes (datetime 1970) 12) #<datetime 1969-12-31T23:48:00>
> (+minutes (moment 2015 3 8 1 23 59 #:tz "America/New_York") 1) #<moment 2015-03-08T01:24:59-05:00[America/New_York]>
> (-minutes (years 5) 20) #<period of 5 years, -20 minutes>
procedure
(+seconds t n) → time-arithmetic-provider?
t : time-arithmetic-provider? n : exact-integer?
procedure
(-seconds t n) → time-arithmetic-provider?
t : time-arithmetic-provider? n : exact-integer?
> (+seconds (time 22) 4) #<time 22:00:04>
> (-seconds (datetime 1970) 12) #<datetime 1969-12-31T23:59:48>
> (+seconds (moment 2015 3 8 1 59 59 #:tz "America/New_York") 1) #<moment 2015-03-08T03:00:00-04:00[America/New_York]>
> (-seconds (years 5) 20) #<period of 5 years, -20 seconds>
procedure
t : time-arithmetic-provider? n : exact-integer?
procedure
t : time-arithmetic-provider? n : exact-integer?
> (+milliseconds (time 22) 4) #<time 22:00:00.004>
> (-milliseconds (datetime 1970) 12) #<datetime 1969-12-31T23:59:59.988>
> (+milliseconds (moment 2015 3 8 1 59 59 999000000 #:tz "America/New_York") 1) #<moment 2015-03-08T03:00:00-04:00[America/New_York]>
> (-milliseconds (years 5) 20) #<period of 5 years, -20 milliseconds>
procedure
t : time-arithmetic-provider? n : exact-integer?
procedure
t : time-arithmetic-provider? n : exact-integer?
> (+microseconds (time 22) 4) #<time 22:00:00.000004>
> (-microseconds (datetime 1970) 12) #<datetime 1969-12-31T23:59:59.999988>
> (+microseconds (moment 2015 3 8 1 59 59 999999000 #:tz "America/New_York") 1) #<moment 2015-03-08T03:00:00-04:00[America/New_York]>
> (-microseconds (years 5) 20) #<period of 5 years, -20 microseconds>
procedure
t : time-arithmetic-provider? n : exact-integer?
procedure
t : time-arithmetic-provider? n : exact-integer?
> (+nanoseconds (time 22) 4) #<time 22:00:00.000000004>
> (-nanoseconds (datetime 1970) 12) #<datetime 1969-12-31T23:59:59.999999988>
> (+nanoseconds (moment 2015 3 8 1 59 59 999999999 #:tz "America/New_York") 1) #<moment 2015-03-08T03:00:00-04:00[America/New_York]>
> (-nanoseconds (years 5) 20) #<period of 5 years, -20 nanoseconds>
procedure
t : time-arithmetic-provider? p : time-period?
procedure
t : time-arithmetic-provider? p : time-period?
> (+time-period (time 22) (hours -4)) #<time 18:00:00>
> (+time-period (moment 2015 3 8 1 59 59 999999999 #:tz "America/New_York") (nanoseconds 1)) #<moment 2015-03-08T03:00:00-04:00[America/New_York]>
> (-time-period (years 6) (seconds 5)) #<period of 6 years, -5 seconds>