## date.api
#
# See also:
#
src/lib/std/src/time.api# Compiled by:
#
src/lib/std/src/standard-core.sublib### "Payday came and with it beer."
###
### -- Rudyard Kipling
stipulate
package ns = number_string; # number_string is from
src/lib/std/src/number-string.pkgherein
api Date {
#
Weekday = MON
| TUE | WED | THU | FRI | SAT | SUN;
Month
= JAN
| FEB | MAR | APR | MAY | JUN
| JUL | AUG | SEP | OCT | NOV | DEC;
Date;
exception BAD_DATE; # raised on errors, as described below
year: Date -> Int; # Returns the year (e::g., 1997)
month: Date -> Month; # Returns the month
day: Date -> Int; # Returns the day of the month
hour: Date -> Int; # Returns the hour
minute: Date -> Int; # Returns the minute
second: Date -> Int; # Returns the second
week_day: Date -> Weekday; # Returns the day of the week
year_day: Date -> Int; # Returns the day of the year
is_daylight_savings_time: Date -> Null_Or( Bool );
#
# Returns THE (TRUE) if daylight savings time is in effect.
# Returns THE (FALSE) if not.
# Returns NULL if we don't know.
offset: Date -> Null_Or( time::Time );
#
# Returns time west of UTC.
# NULL is localtime,
# THE (time::zero_time) is UTC.
local_offset: Void -> time::Time; # offset from UTC for the local time zone
date: {
year: Int,
month: Month,
day: Int,
hour: Int,
minute: Int,
second: Int,
offset: Null_Or( time::Time )
} -> Date;
# Creates a date from the given values.
from_time_local: time::Time -> Date;
#
# Returns the date for the given time in the local timezone.
# This is like the ANSI C function localtime.
# was: fromTime
from_time_univ: time::Time -> Date;
#
# Returns the date for the given time in the UTC timezone.
# This is like the ANSI C function gmtime.
# was: fromUTC
to_time: Date -> time::Time;
#
# Returns the time value corresponding to the date in the
# host system. This raises Date exception if the date cannot
# be represented as a time value.
to_string: Date -> String;
#
# An easy way to get the current time and date as a string like
# "Thu Feb 18 15:44:22 2010"
# is:
# date::to_string (date::from_time_local (time::get()));
strftime: String -> Date -> String;
#
# This just calls the C strftime() function.
# See the STRFTIME(3) Linux manpage ('man strftime').
#
# To get the time and date in descending order, so that
# an alphabetic sort will also be chronological, try:
#
# eval: date::strftime "%Y-%m-%d:%H:%M:%S" (date::from_time_local (time::get_current_time_utc()));
#
# "2010-02-18:15:50:55"
from_string: String -> Null_Or( Date );
scan: ns::Reader (Char, X) ->
ns::Reader (Date, X);
compare: (Date, Date) -> Order; # Returns the relative order of two dates.
#######################################################################
# Below stuff is intended only for one-time use during
# booting, to switch from direct to indirect syscalls: # For background see Note[1] in
src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg Tm = (Int, Int, Int, Int, Int, Int, Int, Int, Int);
ascii_time__syscall: (Tm -> String);
set__ascii_time__ref: ( { lib_name: String, fun_name: String, io_call: (Tm -> String) }
-> (Tm -> String)
)
-> Void;
local_time__syscall: (one_word_int::Int -> Tm);
set__local_time__ref: ( { lib_name: String, fun_name: String, io_call: (one_word_int::Int -> Tm) }
-> (one_word_int::Int -> Tm)
)
-> Void;
greenwich_mean_time__syscall: (one_word_int::Int -> Tm);
set__greenwich_mean_time__ref: ( { lib_name: String, fun_name: String, io_call: (one_word_int::Int -> Tm) }
-> (one_word_int::Int -> Tm)
)
-> Void;
make_time__syscall: (Tm -> one_word_int::Int);
set__make_time__ref: ( { lib_name: String, fun_name: String, io_call: (Tm -> one_word_int::Int) }
-> (Tm -> one_word_int::Int)
)
-> Void;
strftime__syscall: ((String, Tm) -> String);
set__strftime__ref: ( { lib_name: String, fun_name: String, io_call: ((String, Tm) -> String) }
-> ((String, Tm) -> String)
)
-> Void;
};
end;
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.