The Misty Programming Language provides features for dealing with time.
use time
Misty provides three representations of time. The first is simply a number that counts the number of seconds from the epoch. The second is a record containing fields describing the components of a time and date, and the third is a formatted text.
The Misty epoch (or time_{zero}_{}) is "00000101
00:00:00.00 +0000"
, aka January 1 of the year 0. The year
0 was (or would have been) a leap year.
The Unix epoch is "19700101
00:00:00.00 +0000"
, or 62 167 219 200 seconds after the Misty epoch.
time
recordThe time
record contains constants that can be used
when doing time calculations, and methods for converting between representations
of time.
time
constantstime.second : 1
The number of seconds in a second.
time.minute : 60
The number of seconds in a minute.
time.hour : 3_600
The number of seconds in an hour of 60 minutes.
time.day : 86_400
The number of seconds in a day of 24 hours.
time.week : 604_800
The number of seconds in a week of 7 days.
time.month : 2_629_746
The number of seconds in a Gregorian month of 30.436875 days.
time.year : 31_556_952
The number of seconds in a Gregorian year of 365.2425 days
time
functionsThe time
record contains 3 functions.
These inputs are recognized by the time
functions:
time function input type 


parameters ...  interpretation 
( number) 
The number of seconds since the epoch. 
( text, format,
zone) 
A date text in one of several formats. 
( record) 
A record containing any of these fields: year , month , day , seventh , hour ,
minute , second , zone . A missing property is assumed to be zero. 
Numbers can be convenient representations of times. my_date + time.day
is the same time tomorrow. Subtraction can be used to determine the difference
between two times in seconds.
A text can contain a textual representation of a time, such as
"20010911"
or "09/11/01"
or
"13:30:00"
.
A format is a text or record that determines how to interpret the text.
A zone is a numeric indication of the local time zone which is indicated by the date text. For example, if the time in the text is local to California (Pacific Standard Time), then zone will be 8.
A record can be used to specify a time. Each of the fields will be relative
to zero (even month and day which are conventionally shown relative to 1). So time.number({year:
2001, month: 8, day: 10})
has the same result as time.number("20010911")
.
The name of the function indicates the type of the result.
,
format,
zone)
)
The result is the number of seconds since the epoch.
time.text(
number,
format,
zone)
,
format,
zone)
The result is a display text of the date. The value cannot be a text.
The format is either a format text or a format record. A format text contains instructions for formatting the date text.
Symbol  to text  from text  

year  yyyyy 
The year will be displayed in a 5 digit field with zero fill. If
the year is negative and if there is no c or b
in the format, then a leading minus sign will be included. 
Up to 5 digits and an optional leading minus sign. 
yyyy 
The year will be displayed in a 4 digit field with zero fill. If
the year is negative and if there is no c or b
in the format, then a leading minus sign will be included. 
Up to 4 digits and an optional leading minus sign.  
yy 
modulo(year, 100) will be displayed in a 2 digit field
with zero fill. Not recommended. 
Up to 2 digits and an optional leading minus sign. The current century will be added. Not recommended.  
y 
The year will be displayed with as many digits as necessary with no fill. If the year is negative and if there
is no c or b in the format, then a leading
minus sign will be included. 
Same as yyyyy . 

month  mm 
The number of the month (112) in a 2 digit field with zerofill.  Up to 2 digits. 
m 
The month (112).  
day of the year  eee 
The day of the year (1366) in a 3 digit field with zerofill.  Up to 3 digits. 
day of the month  dd 
The day of the month (131) in a 2 digit field with zerofill.  Up to 2 digits. 
d 
The day of the month (131)  
day of the week  v 
The day of the week (06).  One digit. 
ce/bce  c 
If the year is negative, BCE . If the year is positive,
CE . 
CE or BCE or nothing. 
b 
If the year is negative, BCE . If the year is positive,
nothing. 

hours (24)  hh 
The hour (023) in a 2 digit field with zerofill.  Up to 2 digits. 
h 
The hour (023).  
minutes  nn 
The minute (059) in a 2 digit field with zerofill.  Up to 2 digits. 
n 
The minute (059).  
seconds  ss 
The second (059) in a 2 digit field with zerofill.  Up to 2 digits. 
s 
The second (059).  
fraction  ff 
The number of f s determine the number of
digits of fraction of seconds to show. 
Two digits 
f 
One digit  
am/pm  a 
If the hour is 13 or more, subtract 12 from the hour and PM . If the hour is 12, then PM . If the hour is 0, make the hour 12 and AM . Otherwise, AM . 
AM or PM or nothing. If PM , if hour is not 12 then add 12 to hour. If AM or nothing, if hour is 12, set hour to 0. 
zone  z 
The time zone, 12 to +11  12 to +11 or nothing 
separator  t 
T 
T or space. 
     or space. 

: 
: 
: or space. 

/  /  / or space. 

space  space.  space. 
time.record(
number)
time.record(
text,
format,
zone)
The result is a record containing all of these fields: year
,
month
, week
, day_of_year
, day
(of month), day_of_week
, hour
, minute
,
second
. All will have number values. All of the values will
be positive except the year
for dates before the year zero.
All of the fields are relative to zero, including month
and
day
which are conventionally displayed as being relative to 1.
All of the values are integers except for second
which may
have a real value.