timeless
1 Procedure Reference
unix-epoch-time
unix-epoch-date
hours-ago
hours-ago/  time
hours-ago/  date
hours-from-now
hours-from-now/  time
hours-from-now/  date
time-in-range?
time-in-range<>?
time-in-range==?
time-in-range=<>=?
time-in-range=<>?
time-in-range<>=?
beginning-date
beginning-date/  day
beginning-date/  month
beginning-date/  year
end-date
end-date/  day
end-date/  month
end-date/  year
previous-date/  day
yesterday-date
parse-date
previous-date/  month
yesterday-date
last-oclock/  time
last-oclock/  date
last-oclock
oclocks-between
oclocks-between/  time
oclocks-between/  date
time-utc->date->string
time-utc->string
2 Example
7.4

timeless

 (require timeless) package: timeless

a useful time library, is splited from chive and built on the top of srfi 19/time.

source code

    1 Procedure Reference

    2 Example

1 Procedure Reference

value

unix-epoch-time : time?

returns the unix epoch time, which is 1970-01-01T00:00:00Z.

value

unix-epoch-date : date?

returns the unix-epoch-time in date type.

procedure

(hours-ago n)  date?

  n : number?
an alias procedure of hours-ago/date

procedure

(hours-ago/time n)  time?

  n : number?
returns a time of n hours ago.

procedure

(hours-ago/date n)  date?

  n : number?
returns a date of n hours ago.

procedure

(hours-from-now n)  date?

  n : number?
an alias procedure of hours-from-now/date

procedure

(hours-from-now/time n)  time?

  n : number?
returns a time of n hours from now on.

procedure

(hours-from-now/date n)  date?

  n : number?
returns a date of n hours from now on.

same kind of rule comes to procedures days-ago and days-from-now, and the plural procedure name can be singular such as hour-ago.

procedure

(time-in-range? time1 time2 time3)  boolean?

  time1 : time?
  time2 : time?
  time3 : time?
an alias procedure of time-in-range<>?

procedure

(time-in-range<>? time1 time2 time3)  boolean?

  time1 : time?
  time2 : time?
  time3 : time?
Is time1 in the range of time2 and time3?

procedure

(time-in-range==? time1 time2 time3)  boolean?

  time1 : time?
  time2 : time?
  time3 : time?
an alias procedure of time-in-range=<>=?

procedure

(time-in-range=<>=? time1 time2 time3)  boolean?

  time1 : time?
  time2 : time?
  time3 : time?
Is time1 in the range of time2 and time3(is in if time1 equals time2 or time3)?

procedure

(time-in-range=<>? time1 time2 time3)  boolean?

  time1 : time?
  time2 : time?
  time3 : time?
Is time1 in the range of time2 and time3(is in if time1 equals time2)?

procedure

(time-in-range<>=? time1 time2 time3)  boolean?

  time1 : time?
  time2 : time?
  time3 : time?
Is time1 in the range of time2 and time3(is in if time1 equals time3)?

procedure

(beginning-date d)  date?

  d : date?
beginning-date is an alias procedure of beginning-date/day.

procedure

(beginning-date/day d)  date?

  d : date?
beginning-date/day returns a new date which is the first date of the day of d.

procedure

(beginning-date/month d)  date?

  d : date?
beginning-date/month returns a new date which is the first date of the month of d.

procedure

(beginning-date/year d)  date?

  d : date?
beginning-date/year returns a new date which is the first date of the year of d.

procedure

(end-date d)  date?

  d : date?
end-date is an alias procedure of end-date/day.

procedure

(end-date/day d)  date?

  d : date?
end-date/day returns a new date which is the end date of the day of d.

procedure

(end-date/month d)  date?

  d : date?
end-date/month returns a new date which is the end date of the month of d.

procedure

(end-date/year d)  date?

  d : date?
end-date/year returns a new date which is the endt date of the year of d.

procedure

(previous-date/day d)  date?

  d : date?
returns a new date which is the same date of yesterday of d.

procedure

(yesterday-date d)  date?

  d : date?
end-date is an alias procedure of previous-date/day.

procedure

(parse-date str)  date?

  str : string?
try to returns a date with parsing the string str.

procedure

(previous-date/month d)  date?

  d : date?
returns a new date which is the same date of last month of d.

procedure

(yesterday-date d)  date?

  d : date?
end-date is an alias procedure of last-month-date.

procedure

(last-oclock/time d)  time?

  d : time?
returns a new time which is the recently last oclock time of d.

procedure

(last-oclock/date d)  date?

  d : date?
returns a new date which is the recently last oclock time of d.

procedure

(last-oclock d)  date?

  d : date?
an alias procedure of last-oclock/date.

procedure

(oclocks-between d1 d2)  list?

  d1 : date?
  d2 : date?
an alias procedure of oclocks-between/date.

procedure

(oclocks-between/time t1 t2)  list?

  t1 : time?
  t2 : time?
returns a list of all the time oclocks between t1 and t2.

procedure

(oclocks-between/date d1 d2)  list?

  d1 : date?
  d2 : date?
returns a list of all the date oclocks between d1 and d2.

procedure

(time-utc->date->string t [format-string])  string?

  t : time?
  format-string : string? = "~c"
convert the time to date and then to string with format-string of PLT-specific extensions(string->date).

procedure

(time-utc->string t [format-string])  string?

  t : time?
  format-string : string? = "~c"
an alias procedure of time-utc->date->string.

2 Example

(require timeless)
 
(hours-ago 5)
;=> (date* 55 50 11 8 5 2019 3 127 #f 28800 996000000 "")
 
(time-in-range? (days-ago 2) (hours-ago 1) unix-epoch-time)
;=> #t
 
(last-olock (current-date))
;=> #[#{date pfwa3r0havo3glvxa5oa6eoyh-24} 0 0 0 15 5 11 2018 28800]
 
(last-olock/time (current-time))
;=> #[#{date pfwa3r0havo3glvxa5oa6eoyh-24} 0 0 0 15 5 11 2018 28800]
 
> (oclocks-between (hours-ago 2) (hours-ago 5))
(#[#{date pfwa3r0havo3glvxa5oa6eoyh-24} 0 0 0 10 5 11 2018 28800]
 #[#{date pfwa3r0havo3glvxa5oa6eoyh-24} 0 0 0 11 5 11 2018 28800]
 #[#{date pfwa3r0havo3glvxa5oa6eoyh-24} 0 0 0 12 5 11 2018 28800]
 #[#{date pfwa3r0havo3glvxa5oa6eoyh-24} 0 0 0 13 5 11 2018 28800])
 
> (oclocks-between/time (hours-ago/time 2) (hours-ago/time 5))
(#[#{time pfwa3r0havo3glvxa5oa6eoyh-25} time-utc 0 1541383200]
 #[#{time pfwa3r0havo3glvxa5oa6eoyh-25} time-utc 0 1541386800]
 #[#{time pfwa3r0havo3glvxa5oa6eoyh-25} time-utc 0 1541390400]
 #[#{time pfwa3r0havo3glvxa5oa6eoyh-25} time-utc 0 1541394000])
 
 
(require srfi/19)
(beginning-date (current-date))
;=> (date* 0 0 0 5 5 2019 0 124 #f 28800 0 "")
 
(beginning-date/month (current-date))
;=> (date* 0 0 0 1 5 2019 3 120 #f 28800 0 "")
 
(beginning-date/year (current-date))
;=> (date* 0 0 0 1 1 2019 2 0 #f 28800 0 "")
 
(date->string (parse-date "2018-01-01 11:11:11 +0800"))
;=> "Mon Jan 01 11:11:11+0800 2018"
 
(date->string (parse-date "2018/01/01 12"))
;=> "Mon Jan 01 12:00:00+0800 2018"