Skip to content

Instantly share code, notes, and snippets.

@cheeplusplus
Created March 6, 2014 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheeplusplus/9384561 to your computer and use it in GitHub Desktop.
Save cheeplusplus/9384561 to your computer and use it in GitHub Desktop.
Internet time MUF script
( cmd-@@time.muf by Andrew =AndrewNeo=
Written 4-26-03
Please port freely )
(===DETAILS=== Lines 5-7)
( Returns internet time
Use either @@time or
@@time 12:00 in 24 hour style )
( Updated 11-20-03 for a little MPI support )
lvar command
lvar hour
lvar minute
lvar seconds
lvar bmt
lvar sec
lvar smin
lvar shr
lvar sb
lvar cutloc
lvar res
: icvt (i -- s)
(Converts into the three-digit-style for IT)
res !
res @ 10 < if
"00" res @ intostr strcat res !
else
res @ 100 < if
"0" res @ intostr strcat res !
else res @ intostr res !
then then
res @
;
: itime (s m h -- i)
(Take given time and return internet time)
hour ! minute ! seconds !
hour @ gmtoffset 60 / 60 / (NOW=Diff GMT) - ++ bmt !
bmt @ 3600 * minute @ 60 * seconds @ + + sec !
sec @ 86.4 / 0 round int sb !
sb @ 1000 >= if sb @ 1000 - sb ! then sb @
;
: main ( -- )
command !
command @ ":" instr if
command @ dup ":" instr dup cutloc ! strcut atoi smin ! cutloc @ 1 - strcut pop atoi shr !
0 smin @ shr @ itime icvt sb !
"With the time given, it is @" sb @ "." strcat strcat .tell exit
then
"It is currently @" time itime icvt " Internet Time."
strcat strcat .tell "@" time itime icvt strcat exit (exit with the time on stack)
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment