mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-14 08:34:25 +03:00
added utc library
This commit is contained in:
parent
39bf710edf
commit
ff160e0443
121
arvo/zuse.hoon
121
arvo/zuse.hoon
@ -578,7 +578,120 @@
|
||||
~|(%test-fail-seal !!)
|
||||
msg
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
:: section 3bC, JSON and XML ::
|
||||
:: section 3bC, UTC :: Gregorian only
|
||||
::
|
||||
++ dawn :: Jan 1 weekday
|
||||
|= yer=@ud
|
||||
=+ yet=(sub yer 1)
|
||||
%- mod :_ 7
|
||||
:(add 1 (mul 5 (mod yet 4)) (mul 4 (mod yet 100)) (mul 6 (mod yet 400)))
|
||||
::
|
||||
++ daws :: date weekday
|
||||
|= yed=date
|
||||
%- mod :_ 7
|
||||
(add (dawn y.yed) (sub (yawn [y.yed m.yed d.t.yed]) (yawn y.yed 1 1)))
|
||||
::
|
||||
++ deal :: to leap sec time
|
||||
|= yer=@da
|
||||
=+ n=0
|
||||
=+ yud=(yore yer)
|
||||
|- ^- date
|
||||
?: (gte yer (add (snag n lef:yu) ~s1))
|
||||
(yore (year yud(s.t (add n s.t.yud))))
|
||||
?: &((gte yer (snag n lef:yu)) (lth yer (add (snag n lef:yu) ~s1)))
|
||||
yud(s.t (add +(n) s.t.yud))
|
||||
?: =(+(n) (lent lef:yu))
|
||||
(yore (year yud(s.t (add +(n) s.t.yud))))
|
||||
$(n +(n))
|
||||
::
|
||||
++ lead :: from leap sec time
|
||||
|= ley=date
|
||||
=+ ler=(year ley)
|
||||
=+ n=0
|
||||
|- ^- @da
|
||||
=+ led=(sub ler (mul n ~s1))
|
||||
?: (gte ler (add (snag n les:yu) ~s1))
|
||||
led
|
||||
?: &((gte ler (snag n les:yu)) (lth ler (add (snag n les:yu) ~s1)))
|
||||
?: =(s.t.ley 60)
|
||||
(sub led ~s1)
|
||||
led
|
||||
?: =(+(n) (lent les:yu))
|
||||
(sub led ~s1)
|
||||
$(n +(n))
|
||||
::
|
||||
++ dust :: print UTC format
|
||||
|= yed=date
|
||||
^- tape
|
||||
=+ wey=(daws yed)
|
||||
;: weld
|
||||
`tape`(snag wey (turn wik:yu |=(a=tape (scag 3 a))))
|
||||
", " ~(rud at d.t.yed) " "
|
||||
`tape`(snag (dec m.yed) (turn mon:yu |=(a=tape (scag 3 a))))
|
||||
" " (scag 1 ~(rud at y.yed)) (slag 2 ~(rud at y.yed)) " "
|
||||
~(rud at h.t.yed) ":" ~(rud at m.t.yed) ":" ~(rud at s.t.yed)
|
||||
" " "+0000"
|
||||
==
|
||||
::
|
||||
++ stud :: parse UTC format
|
||||
|= cut=tape
|
||||
^- date
|
||||
=+ ^= tuc
|
||||
%+ scan cut
|
||||
;~ plug
|
||||
;~(pfix (stun [5 5] next) dim:ag)
|
||||
%+ cook
|
||||
|= a=tape
|
||||
=+ b=0
|
||||
|- ^- @
|
||||
?: =(a (snag b (turn mon:yu |=(a=tape (scag 3 a)))))
|
||||
b
|
||||
$(b +(b))
|
||||
(ifix [ace ace] (star alf))
|
||||
;~(sfix dim:ag ace) ;~(sfix dim:ag col)
|
||||
;~(sfix dim:ag col) dim:ag (cold ~ (star next))
|
||||
==
|
||||
[[%.y &3.tuc] &2.tuc &1.tuc &4.tuc &5.tuc &6.tuc ~]
|
||||
|
||||
::
|
||||
++ yu :: UTC format constants
|
||||
|%
|
||||
++ mon ^- (list tape)
|
||||
:~ "January" "February" "March" "April" "May" "June" "July"
|
||||
"August" "September" "October" "November" "December"
|
||||
==
|
||||
::
|
||||
++ wik ^- (list tape)
|
||||
:~ "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday"
|
||||
"Friday" "Saturday"
|
||||
==
|
||||
::
|
||||
++ les ^- (list ,@da)
|
||||
:~ ~2012.7.1 ~2009.1.1 ~2006.1.1 ~1999.1.1 ~1997.7.1 ~1996.1.1
|
||||
~1994.7.1 ~1993.7.1 ~1992.7.1 ~1991.1.1 ~1990.1.1 ~1988.1.1
|
||||
~1985.7.1 ~1983.7.1 ~1982.7.1 ~1981.7.1 ~1980.1.1 ~1979.1.1
|
||||
~1978.1.1 ~1977.1.1 ~1976.1.1 ~1975.1.1 ~1974.1.1 ~1973.1.1
|
||||
~1972.7.1
|
||||
==
|
||||
++ lef ^- (list ,@da)
|
||||
:~ ~2012.6.30..23.59.59 ~2008.12.31..23.59.58
|
||||
~2005.12.31..23.59.57 ~1998.12.31..23.59.56
|
||||
~1997.6.30..23.59.55 ~1995.12.31..23.59.54
|
||||
~1994.6.30..23.59.53 ~1993.6.30..23.59.52
|
||||
~1992.6.30..23.59.51 ~1990.12.31..23.59.50
|
||||
~1989.12.31..23.59.49 ~1987.12.31..23.59.48
|
||||
~1985.6.30..23.59.47 ~1983.6.30..23.59.46
|
||||
~1982.6.30..23.59.45 ~1981.6.30..23.59.44
|
||||
~1979.12.31..23.59.43 ~1978.12.31..23.59.42
|
||||
~1977.12.31..23.59.41 ~1976.12.31..23.59.40
|
||||
~1975.12.31..23.59.39 ~1974.12.31..23.59.38
|
||||
~1973.12.31..23.59.37 ~1972.12.31..23.59.36
|
||||
~1972.6.30..23.59.35
|
||||
==
|
||||
--
|
||||
::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
:: section 3bD, JSON and XML ::
|
||||
::
|
||||
++ moon :: mime type to text
|
||||
|= myn=mite
|
||||
@ -816,7 +929,7 @@
|
||||
%+ weld tam
|
||||
`_tam`?~(att bod [' ' (xmla att bod)])
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
:: section 3bD, tree sync ::
|
||||
:: section 3bE, tree sync ::
|
||||
::
|
||||
++ cure :: invert miso
|
||||
|= mis=miso
|
||||
@ -1260,7 +1373,7 @@
|
||||
(durn (curl nyp))
|
||||
--
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
:: section 3bE, names etc ::
|
||||
:: section 3bF, names etc ::
|
||||
::
|
||||
++ clan :: ship to rank
|
||||
|= who=ship ^- rank
|
||||
@ -1863,7 +1976,7 @@
|
||||
?. ?&(?=(%c dis) ?=(?(%v %w %x %y %z) rem)) ~
|
||||
[~ rem (case p.u.ved) q.p.u.fal q.p.u.dyc tyl]
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
:: section 3bF, Arvo models ::
|
||||
:: section 3bG, Arvo models ::
|
||||
::
|
||||
++ acro :: old asym cryptosuite
|
||||
$_ ^? |% :: opaque object
|
||||
|
Loading…
Reference in New Issue
Block a user