@@ -1,289 +1,31 @@
1+
12---
23navhome: /docs/
34---
45
56
67# 3c: urbit time
7−### `++yo`
8−
9− ++ yo :: time constants core
10−
11−Useful constants for interacting with earth time.
12−
13−### `++cet`
14−
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).
18−
19−Produces
20−--------
21−
22−An atom.
23−
24−Source
25−------
26−
27− |% ++ cet 36.524 :: (add 24 (mul 100 365))
28−
29−Examples
30−--------
31−
32− > cet:yo
33− 36.524
34− > (add 365 cet:yo)
35− 36.889
36− > (sub (add 24 (mul 100 365)) cet:yo)
37− 0
38−
39−------------------------------------------------------------------------
40−
41−### `++day`
42−
43−Number of seconds in a day.
44−
45−Produces
46−--------
47−
48−An atom.
49−
50−Source
51−------
52−
53− ++ day 86.400 :: (mul 24 hor)
54−
55−Examples
56−--------
57−
58− > day:yo
59− 86.400
60− > (add 60 day:yo)
61− 86.460
62−
63−------------------------------------------------------------------------
64−
65−### `++era`
66−
67−XX Revisit
68−
69−Produces
70−--------
71−
72−An atom.
73−
74−Source
75−------
76−
77− ++ era 146.097 :: (add 1 (mul 4 cet))
78−
79−Examples
80−--------
81−
82−
83−------------------------------------------------------------------------
84−
85−### `++hor`
86−
87−Seconds in hour
888
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.
91−
92−Produces
93−--------
94−
95−An atom.
96−
97−Source
98−------
99−
100− ++ hor 3.600 :: (mul 60 mit)
101−
102−Examples
103−--------
104−
105− > hor:yo
106− 3.600
107− > (div hor:yo 60)
108− 60
109−
110−------------------------------------------------------------------------
111−
112−### `++jes`
113−
114−XX Revisit
115−
116−Produces
117−--------
118−
119−An atom.
120−
121−Source
122−------
123−
124− ++ jes 106.751.991.084.417 :: (mul 730.692.561 era)
125−
126−Examples
127−--------
128−
129− > jes:yo
130− 106.751.991.084.417
131−
132−------------------------------------------------------------------------
133−
134−### `++mit`
135−
136−Seconds in minute
137−
138−The number of seconds in a minute.
139−
140−Produces
141−--------
142−
143−An atom.
144−
145−Source
146−------
147−
148− ++ mit 60
149−
150−Examples
151−--------
152−
153− > mit:yo
154− 60
155−
156−------------------------------------------------------------------------
157−
158−### `++moh`
159−
160−Days in month
161−
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.
165−
166−Produces
167−--------
168−
169−A `++list` of `@ud`
170−
171−Source
172−------
173−
174− ++ moh `(list @ud)`[31 28 31 30 31 30 31 31 30 31 30 31 ~]
175−
176−Examples
177−--------
178−
179− > moh:yo
180− ~[31 28 31 30 31 30 31 31 30 31 30 31]
181− > (snag 4 moh:yo)
182− 31
183−
184−------------------------------------------------------------------------
185−
186−### `++moy`
187−
188−Moh with leapyear
189−
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.
193−
194−Examples
195−--------
196−
197−A `++list` of `@ud`
198−
199−Source
200−------
201−
202− ++ moy `(list @ud)`[31 29 31 30 31 30 31 31 30 31 30 31 ~]
203−
204−Examples
205−--------
206−
207− > moy:yo
208− ~[31 29 31 30 31 30 31 31 30 31 30 31]
209− > (snag 1 moy:yo)
210− 29
211−
212−------------------------------------------------------------------------
213−
214−### `++qad`
215−
216−Seconds in 4 years
217−
218−The number of seconds in four years. Derived by adding one second to the
219−number of seconds in four years.
220−
221−Produces
222−--------
223−
224−An atom.
225−
226−Source
227−------
228−
229− ++ qad 126.144.001 :: (add 1 (mul 4 yer))
230−
231−Examples
232−--------
233−
234− > qad:yo
235− 126.144.001
236−
237−------------------------------------------------------------------------
238−
239−### `++yer`
240−
241−Seconds in year
242−
243−The number of seconds in a year. Derived by multiplying the number of
244−seconds in a day by 365.
245−
246−Produces
247−--------
248−
249−An atom.
250−
251−Source
252−------
253−
254− ++ yer 31.536.000 :: (mul 365 day)
255−
256−Examples
257−--------
258−
259− > yer:yo
260− 31.536.000
261−
262−
263−
264−***
2659### `++yall`
26610
26711Time since beginning of time
26812
26913Produce 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.
27115
272−Accepts
273−-------
16+#### Accepts
27417
275−`day` is a [`@ud`]()
18+`day` is a an unsigned decimal.
27619
277−Produces
278−--------
20+#### Produces
27921
22+A cell of unsigned decimals.
28023
281−Source
282−------
24+#### Source
28325
284− ++ yall :: day / to day of year
285− |= day/@ud
286− ^- {y/@ud m/@ud d/@ud}
26+ ++ yall
27+ |= day=@ud
28+ ^- [y=@ud m=@ud d=@ud]
28729 =+ [era=0 cet=0 lep=*?]
28830 => .(era (div day era:yo), day (mod day era:yo))
28931 => ^+ .
@@ -292,27 +34,28 @@ Source
29234 => .(lep |, cet 1, day (sub day +(cet:yo)))
29335 .(cet (add cet (div day cet:yo)), day (mod day cet:yo))
29436 =+ yer=(add (mul 400 era) (mul 100 cet))
295− |- ^- {y/@ud m/@ud d/@ud}
37+ |- ^- [y=@ud m=@ud d=@ud]
29638 =+ dis=?:(lep 366 365)
29739 ?. (lth day dis)
29840 =+ ner=+(yer)
29941 $(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]
30143 =+ [mot=0 cah=?:(lep moy:yo moh:yo)]
302− |- ^- {y/@ud m/@ud d/@ud}
44+ |- ^- [y=@ud m=@ud d=@ud]
30345 =+ zis=(snag mot cah)
30446 ?: (lth day zis)
30547 [yer +(mot) +(day)]
30648 $(mot +(mot), day (sub day zis))
307− ::
30849
309−Examples
310−--------
50+
51+#### Examples
31152
31253 > (yall 198)
31354 [y=0 m=7 d=17]
55+
31456 > (yall 90.398)
31557 [y=247 m=7 d=3]
58+
31659 > (yall 0)
31760 [y=0 m=1 d=1]
31861
@@ -326,25 +69,22 @@ Days since beginning of time
32669Inverse of `yall`, computes number of days A.D. from y/m/d date as the
32770tuple `[yer=@ud mot=@ud day=@ud]`.
32871
329−Accepts
330−-------
72+#### Accepts
33173
332−`yer` is an unsigned decimal, `@ud`.
74+`yer` is an unsigned decimal.
33375
334−`mon` is an unsigned decimal, `@ud`.
76+`mon` is an unsigned decimal.
33577
336−`day` is an unsigned decimal, `@ud`.
78+`day` is an unsigned decimal.
33779
338−Produces
339−--------
80+#### Produces
34081
341−A `@ud`.
82+An unsigned decimal.
34283
343−Source
344−------
84+#### Source
34585
346− ++ yawn :: days since Jesus
347− |= {yer/@ud mot/@ud day/@ud}
86+ ++ yawn
87+ |= [yer=@ud mot=@ud day=@ud]
34888 ^- @ud
34989 => .(mot (dec mot), day (dec day))
35090 => ^+ .
@@ -367,41 +107,39 @@ Source
367107 =+ nec=(sub yer 100)
368108 $(yer nec, day (add day ?:((yelp nec) 36.525 36.524)))
369109 (add day (mul (div yer 400) (add 1 (mul 4 36.524))))
370− ::
371110
372−Examples
373−--------
111+#### Examples
112+
113+ > (yawn 2.018 7 4)
114+ 737.244
374115
375− > (yawn 2.014 8 4)
376− 735.814
377116 > (yawn 1.776 7 4)
378117 648.856
118+
379119 > (yawn 1.990 10 11)
380120 727.116
381121
382122
383−
384123***
385124### `++year`
386125
126+Date to @d
127+
387128Accept a parsed date of form `[[a=? y=@ud] m=@ud t=tarp]` and produce
388−its `@d`representation.
129+its `@d` representation.
389130
390−Accepts
391−-------
131+#### Accepts
392132
393−`det` is a `++date`
133+`det` is a `date`
394134
395−Produces
396−--------
135+#### Produces
397136
398137A `@d`.
399138
400−Source
401−------
139+#### Source
402140
403− ++ year :: date to @d
404− |= det/date
141+ ++ year
142+ |= det=date
405143 ^- @da
406144 =+ ^= yer
407145 ?: a.det
@@ -409,28 +147,33 @@ Source
409147 (sub 292.277.024.400 (dec y.det))
410148 =+ day=(yawn yer m.det d.t.det)
411149 (yule day h.t.det m.t.det s.t.det f.t.det)
412− ::
413150
414−Examples
415−--------
151+
152+#### Examples
416153
417154 > (year [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=4 s=57 f=~[0xd940]]])
418155 0x8000000d227df4e9d940000000000000
419156
420157
421−
422158***
423159### `++yell`
424160
425−Produce a parsed daily time format from an atomic date.
161+Tarp from atomic date
162+
163+Produce a parsed daily time format from, `@d`, an atomic date.
164+
165+#### Accepts
426166
427167`now` is a `@d`.
428168
429−Source
430−------
169+#### Produces
170+
171+A `tarp`.
172+
173+#### Source
431174
432− ++ yell :: tarp from @d
433− |= now/@d
175+ ++ yell
176+ |= now=@d
434177 ^- tarp
435178 =+ sec=(rsh 6 1 now)
436179 =+ ^= fan
@@ -447,16 +190,16 @@ Source
447190 =+ mit=(div sec mit:yo)
448191 => .(sec (mod sec mit:yo))
449192 [day hor mit sec fan]
450− ::
451193
452194
453−Examples
454−--------
195+#### Examples
455196
456197 > (yell ~2014.3.20..05.42.53..7456)
457198 [d=106.751.991.820.094 h=5 m=42 s=53 f=~[0x7456]]
199+
458200 > (yell ~2014.6.9..19.09.40..8b66)
459201 [d=106.751.991.820.175 h=19 m=9 s=40 f=~[0x8b66]]
202+
460203 > (yell ~1776.7.4)
461204 [d=106.751.991.733.273 h=0 m=0 s=0 f=~]
462205
@@ -466,60 +209,56 @@ Examples
466209
467210Leap-week?
468211
469−Determines whether a year contains an ISO 8601 leap week. Produces a
470−loobean.
212+Determines whether a year contains an ISO 8601 leap-week. Produces a flag.
471213
472−Accepts
473−-------
214+#### Accepts
474215
475−`yer` is an unsigned decimal, `@ud`.
216+`yer` is an unsigned decimal.
476217
477−Produces
478−--------
218+#### Produces
479219
480−A boolean.
220+A flag.
481221
482−Source
483−------
222+#### Source
484223
485− ++ yelp :: leap year
224+ ++ yelp
486225 |= yer=@ud ^- ?
487226 &(=(0 (mod yer 4)) |(!=(0 (mod yer 100)) =(0 (mod yer 400))))
488227
489−Examples
490−--------
228+#### Examples
491229
492230 > (yelp 2.014)
493231 %.n
232+
494233 > (yelp 2.008)
495234 %.y
235+
496236 > (yelp 0)
497237 %.y
238+
498239 > (yelp 14.011)
499240 %.n
500241
501242
502−
503243***
504244### `++yore`
505245
506−Produces a `++date` from a `@d`
246+Date from atomic date
507247
508−Accepts
509−-------
248+Produces a `date` from a `@d`.
510249
511−`now` is a `@d`.
250+#### Accepts
251+
252+`now` is a time atom, `@d`.
512253
513−Produces
514−--------
254+#### Produces
515255
516−A `++date`.
256+A `date`.
517257
518−Source
519−------
258+#### Source
520259
521− ++ yore :: @d to date
522− |= now/@da
260+ ++ yore
261+ |= now=@da
523262 ^- date
524263 =+ rip=(yell now)
525264 =+ ger=(yall d.rip)
@@ -527,16 +266,12 @@ Source
527266 [a=& y=(sub y.ger 292.277.024.400)]
528267 [a=| y=+((sub 292.277.024.400 y.ger))]
529268 [m.ger d.ger h.rip m.rip s.rip f.rip]
530− ::
531269
532−Examples
533−--------
534270
535− > (yore -<-)
536− [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=17 s=1 f=~[0x700d]]]
537− > (yore -<-)
538− [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=28 s=53 f=~[0x7b82]]]
271+#### Examples
539272
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]]]
540275
541276
542277***
@@ -544,24 +279,21 @@ Examples
544279
545280Daily time to time atom
546281
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,
548283`@d`.
549284
550−Accepts
551−-------
285+#### Accepts
552286
553−`rip` is a `++tarp`.
287+`rip` is a `tarp`.
554288
555−Produces
556−--------
289+#### Produces
557290
558−A `@d`.
291+A time atom, `@d`.
559292
560−Source
561−------
293+#### Source
562294
563295 ++ yule :: time atom
564− |= rip/tarp
296+ |= rip=tarp
565297 ^- @d
566298 =+ ^= sec ;: add
567299 (mul d.rip day:yo)
@@ -578,23 +310,287 @@ Source
578310 (con (lsh 6 1 sec) fac)
579311 ::
580312
581−Examples
582−--------
313+#### Examples
583314
584315 > =murica (yell ~1776.7.4)
316+
585317 > murica
586318 [d=106.751.991.733.273 h=0 m=0 s=0 f=~]
319+
587320 > (yule murica)
588321 0x8000000b62aaf5800000000000000000
322+
589323 > `@da`(yule murica)
590324 ~1776.7.4
325+
591326 > `@da`(yule (yell ~2014.3.20..05.42.53..7456))
592327 ~2014.3.20..05.42.53..7456
328+
593329 > `tarp`[31 12 30 0 ~]
594330 [d=31 h=12 m=30 s=0 f=~]
331+
595332 > `@dr`(yule `tarp`[31 12 30 0 ~])
596333 ~d31.h12.m30
597334
598335
336+***
337+### `++yo`
338+
339+Time constants core
340+
341+Core whose arms contain constants for interacting with earth time.
342+
343+#### Source
344+
345+ ++ yo
346+
347+***
348+### `++cet:yo`
349+
350+Days in a century
351+
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).
355+
356+#### Produces
357+
358+An atom.
359+
360+#### Source
361+
362+ |% ++ cet 36.524
363+
364+#### Examples
365+
366+ > cet:yo
367+ 36.524
368+
369+ > (add 365 cet:yo)
370+ 36.889
371+
372+ > (sub (add 24 (mul 100 365)) cet:yo)
373+ 0
374+
375+
376+***
377+### `++day:yo`
378+
379+Seconds in day
380+
381+The number of seconds in a day.
382+
383+#### Produces
384+
385+An atom.
386+
387+#### Source
388+
389+ ++ day 86.400
390+
391+#### Examples
392+
393+ > day:yo
394+ 86.400
395+
396+ > (add 60 day:yo)
397+ 86.460
398+
399+***
400+### `++era:yo`
401+
402+Leap-year period
403+
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.
407+
408+#### Produces
409+
410+An atom.
411+
412+#### Source
413+
414+ ++ era 146.097
415+
416+#### Examples
417+
418+ > era:yo
419+ 146.097
420+
421+ > (sub era:yo (mul 4 cet:yo))
422+ 1
423+
424+#### Discussion
425+
426+A year is a leap-year if:
427+
428+ - it's divisible by 4;
429+ - *unless* it's divisible by 100;
430+ - *or* if it's divisible by 400.
431+
432+***
433+### `++hor:yo`
434+
435+Seconds in hour
436+
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.
439+
440+#### Produces
441+
442+An atom.
443+
444+#### Source
445+
446+ ++ hor 3.600
447+
448+#### Examples
449+
450+ > hor:yo
451+ 3.600
452+
453+ > (div hor:yo 60)
454+ 60
455+
456+***
457+### `++jes:yo`
458+
459+Maximum 64-bit timestamp
460+
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.
463+
464+#### Produces
465+
466+An atom.
467+
468+#### Source
469+
470+ ++ jes 106.751.991.084.417
471+
472+#### Examples
473+
474+ > jes:yo
475+ 106.751.991.084.417
476+
477+
478+#### Discussion
479+
480+The date is December 4, 292,277,026,596.
481+
482+***
483+### `++mit:yo`
484+
485+Seconds in minute
486+
487+The number of seconds in a minute.
488+
489+#### Produces
490+
491+An atom.
492+
493+#### Source
494+
495+ ++ mit 60
496+
497+#### Examples
498+
499+ > mit:yo
500+ 60
501+
502+***
503+### `++moh:yo`
504+
505+Days in month
506+
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.
510+
511+#### Produces
512+
513+A `list` of `@ud`
514+
515+#### Source
516+
517+ ++ moh `(list @ud)`[31 28 31 30 31 30 31 31 30 31 30 31 ~]
518+
519+#### Examples
520+
521+ > moh:yo
522+ ~[31 28 31 30 31 30 31 31 30 31 30 31]
523+
524+ > (snag 4 moh:yo)
525+ 31
526+
527+
528+***
529+### `++moy:yo`
530+
531+Days in months of leap-year
532+
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.
536+
537+#### Produces
538+
539+A `list` of `@ud`.
540+
541+#### Source
542+
543+ ++ moy `(list @ud)`[31 29 31 30 31 30 31 31 30 31 30 31 ~]
544+
545+#### Examples
546+
547+ > moy:yo
548+ ~[31 29 31 30 31 30 31 31 30 31 30 31]
549+
550+ > (snag 1 moy:yo)
551+ 29
552+
553+***
554+### `++qad:yo`
555+
556+Seconds in 4 years
557+
558+The number of seconds in four years. Derived by adding one second to the
559+number of seconds in four years.
560+
561+#### Produces
562+
563+An atom.
564+
565+#### Source
566+
567+ ++ qad 126.144.001
568+
569+#### Examples
570+
571+ > qad:yo
572+ 126.144.001
573+
574+***
575+### `++yer:yo`
576+
577+Seconds in year
578+
579+The number of seconds in a year. Derived by multiplying the number of
580+seconds in a day by 365.
581+
582+#### Produces
583+
584+An atom.
585+
586+#### Source
587+
588+ ++ yer 31.536.000
589+
590+#### Examples
591+
592+ > yer:yo
593+ 31.536.000
594+
599595
600596***