@@ -1,289 +1,31 @@
2navhome: /docs/
3navhome: /docs/
6# 3c: urbit time
7# 3c: urbit time
9− ++ yo :: time constants core
11−Useful constants for interacting with earth time.
15−Days in a century. Derived by multiplying the number of days in a year
16−(365) by the number of years in a century (100), then adding the number
17−days from leap years in a century (24).
27− |% ++ cet 36.524 :: (add 24 (mul 100 365))
36− > (sub (add 24 (mul 100 365)) cet:yo)
39−------------------------------------------------------------------------
43−Number of seconds in a day.
53− ++ day 86.400 :: (mul 24 hor)
63−------------------------------------------------------------------------
77− ++ era 146.097 :: (add 1 (mul 4 cet))
83−------------------------------------------------------------------------
89−The number of seconds in an hour. Derived by multiplying the number of
90−seconds in a minute by the minutes in an hour.
100− ++ hor 3.600 :: (mul 60 mit)
110−------------------------------------------------------------------------
124− ++ jes 106.751.991.084.417 :: (mul 730.692.561 era)
132−------------------------------------------------------------------------
138−The number of seconds in a minute.
156−------------------------------------------------------------------------
162−The days in each month of the Gregorian common year. A list of unsigned
163−decimal atoms (Either 28, 30, or 31) denoting the number of days in the
164−month at the year at that index.
174− ++ moh `(list @ud)`[31 28 31 30 31 30 31 31 30 31 30 31 ~]
180− ~[31 28 31 30 31 30 31 31 30 31 30 31]
184−------------------------------------------------------------------------
190−The days in each month of the Gregorian leap-year. A list of unsigned
191−decimal atoms (Either 29,30, or 31) denoting the number of days in the
192−month at the leap-year at that index.
202− ++ moy `(list @ud)`[31 29 31 30 31 30 31 31 30 31 30 31 ~]
208− ~[31 29 31 30 31 30 31 31 30 31 30 31]
212−------------------------------------------------------------------------
218−The number of seconds in four years. Derived by adding one second to the
219−number of seconds in four years.
229− ++ qad 126.144.001 :: (add 1 (mul 4 yer))
237−------------------------------------------------------------------------
243−The number of seconds in a year. Derived by multiplying the number of
244−seconds in a day by 365.
254− ++ yer 31.536.000 :: (mul 365 day)
265### `++yall`
9### `++yall`
267Time since beginning of time
11Time since beginning of time
269Produce the date tuple of `[y=@ud m=@ud d=@ud]` of the year, month, and
13Produce the date tuple of `[y=@ud m=@ud d=@ud]` of the year, month, and
270−day from a number of days from the beginning of time.
14+day from a number of days from the beginning of the Gregorian calendar.
272−Accepts
16+#### Accepts
275−`day` is a [`@ud`]()
18+`day` is a an unsigned decimal.
277−Produces
20+#### Produces
22+A cell of unsigned decimals.
284− ++ yall :: day / to day of year
26+ ++ yall
285− |= day/@ud
27+ |= day=@ud
286− ^- {y/@ud m/@ud d/@ud}
28+ ^- [y=@ud m=@ud d=@ud]
287 =+ [era=0 cet=0 lep=*?]
29 =+ [era=0 cet=0 lep=*?]
288 => .(era (div day era:yo), day (mod day era:yo))
30 => .(era (div day era:yo), day (mod day era:yo))
@@ -292,27 +34,28 @@ Source
292 => .(lep |, cet 1, day (sub day +(cet:yo)))
34 => .(lep |, cet 1, day (sub day +(cet:yo)))
293 .(cet (add cet (div day cet:yo)), day (mod day cet:yo))
35 .(cet (add cet (div day cet:yo)), day (mod day cet:yo))
294 =+ yer=(add (mul 400 era) (mul 100 cet))
36 =+ yer=(add (mul 400 era) (mul 100 cet))
295− |- ^- {y/@ud m/@ud d/@ud}
37+ |- ^- [y=@ud m=@ud d=@ud]
296 =+ dis=?:(lep 366 365)
38 =+ dis=?:(lep 366 365)
297 ?. (lth day dis)
39 ?. (lth day dis)
298 =+ ner=+(yer)
40 =+ ner=+(yer)
299 $(yer ner, day (sub day dis), lep =(0 (end 0 2 ner)))
41 $(yer ner, day (sub day dis), lep =(0 (end 0 2 ner)))
300− |- ^- {y/@ud m/@ud d/@ud}
42+ |- ^- [y=@ud m=@ud d=@ud]
301 =+ [mot=0 cah=?:(lep moy:yo moh:yo)]
43 =+ [mot=0 cah=?:(lep moy:yo moh:yo)]
302− |- ^- {y/@ud m/@ud d/@ud}
44+ |- ^- [y=@ud m=@ud d=@ud]
303 =+ zis=(snag mot cah)
45 =+ zis=(snag mot cah)
304 ?: (lth day zis)
46 ?: (lth day zis)
305 [yer +(mot) +(day)]
47 [yer +(mot) +(day)]
306 $(mot +(mot), day (sub day zis))
48 $(mot +(mot), day (sub day zis))
309−Examples
51+#### Examples
312 > (yall 198)
53 > (yall 198)
313 [y=0 m=7 d=17]
54 [y=0 m=7 d=17]
314 > (yall 90.398)
56 > (yall 90.398)
315 [y=247 m=7 d=3]
57 [y=247 m=7 d=3]
316 > (yall 0)
59 > (yall 0)
317 [y=0 m=1 d=1]
60 [y=0 m=1 d=1]
@@ -326,25 +69,22 @@ Days since beginning of time
326Inverse of `yall`, computes number of days A.D. from y/m/d date as the
69Inverse of `yall`, computes number of days A.D. from y/m/d date as the
327tuple `[yer=@ud mot=@ud day=@ud]`.
70tuple `[yer=@ud mot=@ud day=@ud]`.
329−Accepts
72+#### Accepts
332−`yer` is an unsigned decimal, `@ud`.
74+`yer` is an unsigned decimal.
334−`mon` is an unsigned decimal, `@ud`.
76+`mon` is an unsigned decimal.
336−`day` is an unsigned decimal, `@ud`.
78+`day` is an unsigned decimal.
338−Produces
80+#### Produces
341−A `@ud`.
82+An unsigned decimal.
346− ++ yawn :: days since Jesus
86+ ++ yawn
347− |= {yer/@ud mot/@ud day/@ud}
87+ |= [yer=@ud mot=@ud day=@ud]
349 => .(mot (dec mot), day (dec day))
89 => .(mot (dec mot), day (dec day))
@@ -367,41 +107,39 @@ Source
367 =+ nec=(sub yer 100)
107 =+ nec=(sub yer 100)
368 $(yer nec, day (add day ?:((yelp nec) 36.525 36.524)))
108 $(yer nec, day (add day ?:((yelp nec) 36.525 36.524)))
369 (add day (mul (div yer 400) (add 1 (mul 4 36.524))))
109 (add day (mul (div yer 400) (add 1 (mul 4 36.524))))
372−Examples
111+#### Examples
377 > (yawn 1.776 7 4)
116 > (yawn 1.776 7 4)
379 > (yawn 1.990 10 11)
119 > (yawn 1.990 10 11)
385### `++year`
124### `++year`
387Accept a parsed date of form `[[a=? y=@ud] m=@ud t=tarp]` and produce
128Accept a parsed date of form `[[a=? y=@ud] m=@ud t=tarp]` and produce
388−its `@d`representation.
129+its `@d` representation.
390−Accepts
131+#### Accepts
393−`det` is a `++date`
133+`det` is a `date`
395−Produces
135+#### Produces
400−Source
139+#### Source
403− ++ year :: date to @d
141+ ++ year
404− |= det/date
142+ |= det=date
406 =+ ^= yer
144 =+ ^= yer
@@ -409,28 +147,33 @@ Source
409 (sub 292.277.024.400 (dec y.det))
147 (sub 292.277.024.400 (dec y.det))
410 =+ day=(yawn yer m.det d.t.det)
148 =+ day=(yawn yer m.det d.t.det)
411 (yule day h.t.det m.t.det s.t.det f.t.det)
149 (yule day h.t.det m.t.det s.t.det f.t.det)
414−Examples
152+#### Examples
417 > (year [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=4 s=57 f=~[0xd940]]])
154 > (year [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=4 s=57 f=~[0xd940]]])
418 0x8000000d227df4e9d940000000000000
155 0x8000000d227df4e9d940000000000000
423### `++yell`
159### `++yell`
161+Tarp from atomic date
425−Produce a parsed daily time format from an atomic date.
163+Produce a parsed daily time format from, `@d`, an atomic date.
427`now` is a `@d`.
167`now` is a `@d`.
429−Source
173+#### Source
432− ++ yell :: tarp from @d
175+ ++ yell
433− |= now/@d
176+ |= now=@d
435 =+ sec=(rsh 6 1 now)
178 =+ sec=(rsh 6 1 now)
436 =+ ^= fan
179 =+ ^= fan
@@ -447,16 +190,16 @@ Source
447 =+ mit=(div sec mit:yo)
190 =+ mit=(div sec mit:yo)
448 => .(sec (mod sec mit:yo))
191 => .(sec (mod sec mit:yo))
449 [day hor mit sec fan]
192 [day hor mit sec fan]
453−Examples
195+#### Examples
456 > (yell ~2014.3.20..05.42.53..7456)
197 > (yell ~2014.3.20..05.42.53..7456)
457 [d=106.751.991.820.094 h=5 m=42 s=53 f=~[0x7456]]
198 [d=106.751.991.820.094 h=5 m=42 s=53 f=~[0x7456]]
458 > (yell ~2014.6.9..19.09.40..8b66)
200 > (yell ~2014.6.9..19.09.40..8b66)
459 [d=106.751.991.820.175 h=19 m=9 s=40 f=~[0x8b66]]
201 [d=106.751.991.820.175 h=19 m=9 s=40 f=~[0x8b66]]
460 > (yell ~1776.7.4)
203 > (yell ~1776.7.4)
461 [d=106.751.991.733.273 h=0 m=0 s=0 f=~]
204 [d=106.751.991.733.273 h=0 m=0 s=0 f=~]
@@ -466,60 +209,56 @@ Examples
467Leap-week?
210Leap-week?
469−Determines whether a year contains an ISO 8601 leap week. Produces a
212+Determines whether a year contains an ISO 8601 leap-week. Produces a flag.
472−Accepts
214+#### Accepts
475−`yer` is an unsigned decimal, `@ud`.
216+`yer` is an unsigned decimal.
477−Produces
218+#### Produces
480−A boolean.
220+A flag.
482−Source
222+#### Source
485− ++ yelp :: leap year
224+ ++ yelp
486 |= yer=@ud ^- ?
225 |= yer=@ud ^- ?
487 &(=(0 (mod yer 4)) |(!=(0 (mod yer 100)) =(0 (mod yer 400))))
226 &(=(0 (mod yer 4)) |(!=(0 (mod yer 100)) =(0 (mod yer 400))))
489−Examples
228+#### Examples
492 > (yelp 2.014)
230 > (yelp 2.014)
494 > (yelp 2.008)
233 > (yelp 2.008)
496 > (yelp 0)
236 > (yelp 0)
498 > (yelp 14.011)
239 > (yelp 14.011)
504### `++yore`
244### `++yore`
506−Produces a `++date` from a `@d`
246+Date from atomic date
508−Accepts
248+Produces a `date` from a `@d`.
511−`now` is a `@d`.
252+`now` is a time atom, `@d`.
513−Produces
254+#### Produces
516−A `++date`.
256+A `date`.
518−Source
258+#### Source
521− ++ yore :: @d to date
260+ ++ yore
522− |= now/@da
261+ |= now=@da
524 =+ rip=(yell now)
263 =+ rip=(yell now)
525 =+ ger=(yall d.rip)
264 =+ ger=(yall d.rip)
@@ -527,16 +266,12 @@ Source
527 [a=& y=(sub y.ger 292.277.024.400)]
266 [a=& y=(sub y.ger 292.277.024.400)]
528 [a=| y=+((sub 292.277.024.400 y.ger))]
267 [a=| y=+((sub 292.277.024.400 y.ger))]
529 [m.ger d.ger h.rip m.rip s.rip f.rip]
268 [m.ger d.ger h.rip m.rip s.rip f.rip]
535− > (yore -<-)
271+#### Examples
536− [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=17 s=1 f=~[0x700d]]]
538− [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=28 s=53 f=~[0x7b82]]]
273+ > (yore ~2014.6.6..21.09.15..0a16)
274+ [[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]]
@@ -544,24 +279,21 @@ Examples
545Daily time to time atom
280Daily time to time atom
547−Accept a `++tarp`, a parsed daily time, and produces a time atom,
282+Accepts a `tarp`, a parsed daily time, and produces a time atom,
550−Accepts
285+#### Accepts
553−`rip` is a `++tarp`.
287+`rip` is a `tarp`.
555−Produces
289+#### Produces
558−A `@d`.
291+A time atom, `@d`.
560−Source
293+#### Source
563 ++ yule :: time atom
295 ++ yule :: time atom
564− |= rip/tarp
296+ |= rip=tarp
566 =+ ^= sec ;: add
298 =+ ^= sec ;: add
567 (mul d.rip day:yo)
299 (mul d.rip day:yo)
@@ -578,23 +310,287 @@ Source
578 (con (lsh 6 1 sec) fac)
310 (con (lsh 6 1 sec) fac)
581−Examples
313+#### Examples
584 > =murica (yell ~1776.7.4)
315 > =murica (yell ~1776.7.4)
586 [d=106.751.991.733.273 h=0 m=0 s=0 f=~]
318 [d=106.751.991.733.273 h=0 m=0 s=0 f=~]
587 > (yule murica)
320 > (yule murica)
588 0x8000000b62aaf5800000000000000000
321 0x8000000b62aaf5800000000000000000
589 > `@da`(yule murica)
323 > `@da`(yule murica)
590 ~1776.7.4
324 ~1776.7.4
591 > `@da`(yule (yell ~2014.3.20..05.42.53..7456))
326 > `@da`(yule (yell ~2014.3.20..05.42.53..7456))
592 ~2014.3.20..05.42.53..7456
327 ~2014.3.20..05.42.53..7456
593 > `tarp`[31 12 30 0 ~]
329 > `tarp`[31 12 30 0 ~]
594 [d=31 h=12 m=30 s=0 f=~]
330 [d=31 h=12 m=30 s=0 f=~]
595 > `@dr`(yule `tarp`[31 12 30 0 ~])
332 > `@dr`(yule `tarp`[31 12 30 0 ~])
596 ~d31.h12.m30
333 ~d31.h12.m30
341+Core whose arms contain constants for interacting with earth time.
352+Derived by multiplying the number of days in a year
353+(365) by the number of years in a century (100), then adding the number
354+days from leap-years in a century (24).
372+ > (sub (add 24 (mul 100 365)) cet:yo)
381+The number of seconds in a day.
404+The number of days in a 400-year period, arrived at by multiplying `cet` by four
405+and adding one. This is done because every 400 years, there is a leap-year where
406+there would otherwise not be.
421+ > (sub era:yo (mul 4 cet:yo))
426+A year is a leap-year if:
428+ - it's divisible by 4;
429+ - *unless* it's divisible by 100;
430+ - *or* if it's divisible by 400.
437+The number of seconds in an hour. Derived by multiplying the number of
438+seconds in a minute by the minutes in an hour.
459+Maximum 64-bit timestamp
461+This is the number of days (starting from 1970) that can be represented in a
462+64-bit timestamp. Derived by multiplying `era:yo` by 730,692,561.
470+ ++ jes 106.751.991.084.417
480+The date is December 4, 292,277,026,596.
487+The number of seconds in a minute.
507+The days in each month of the Gregorian common year. A list of unsigned
508+decimal atoms (Either 28, 30, or 31) denoting the number of days in the
509+month at the year at that index.
517+ ++ moh `(list @ud)`[31 28 31 30 31 30 31 31 30 31 30 31 ~]
522+ ~[31 28 31 30 31 30 31 31 30 31 30 31]
531+Days in months of leap-year
533+The days in each month of the Gregorian leap-year. A list of unsigned
534+decimal atoms (Either 29, 30, or 31) denoting the number of days in the
535+month at the leap-year at that index.
543+ ++ moy `(list @ud)`[31 29 31 30 31 30 31 31 30 31 30 31 ~]
548+ ~[31 29 31 30 31 30 31 31 30 31 30 31]
558+The number of seconds in four years. Derived by adding one second to the
559+number of seconds in four years.
579+The number of seconds in a year. Derived by multiplying the number of
580+seconds in a day by 365.