PreviousUpNext

15.3.539  src/lib/std/src/time.api

## time.api

# Compiled by:
#     src/lib/std/src/standard-core.sublib

# Implemented in:
#     src/lib/std/src/time-guts.pkg


###            "Eternity is a very long time, especially towards the end."
###
###                                            -- Stephen Hawking



api Time {
    #
    eqtype Time;

    exception TIME;

    zero_time:  Time;


    to_seconds:         Time -> multiword_int::Int;    from_seconds:            multiword_int::Int -> Time;
    to_milliseconds:    Time -> multiword_int::Int;    from_milliseconds:       multiword_int::Int -> Time;
    to_microseconds:    Time -> multiword_int::Int;    from_microseconds:       multiword_int::Int -> Time;
    to_nanoseconds:     Time -> multiword_int::Int;    from_nanoseconds:        multiword_int::Int -> Time;

    to_string:          Time -> String;
    to_float_seconds:   Time -> Float;

    from_string:        String -> Null_Or(Time);
    from_float_seconds: Float  -> Time;

    +  : (Time, Time) -> Time;
    -  : (Time, Time) -> Time;

    compare:  (Time, Time) -> Order;

    <  : (Time, Time) -> Bool;
    <= : (Time, Time) -> Bool;
    >  : (Time, Time) -> Bool;
    >= : (Time, Time) -> Bool;

    get_current_time_utc:  Void -> Time;

    # Format time as a string.
    # First argument is precision:
    #
    #   eval:  time::format 0 (time::get ());
    #
    #   "1258134720"
    #
    #   eval:  time::format 4 (time::get ());
    #
    #   "1258134742.5852"
    #
    #   eval:  time::format 6 (time::get ());
    #
    #   "1258134732.273621"
    #
    # For more date formatting
    # see date::strftime () in
    #
    #     src/lib/std/src/date.api
    #
    format: Int -> Time -> String;

    # Scan a time value.
    # Supported syntax is:
    #
    #    [+-~]?([0-9]+(.[0-9]+)? | .[0-9]+)
    #
    scan:         number_string::Reader (Char, X) -> number_string::Reader (Time, X);

};              # The End of Time.


## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2012,
## released under Gnu Public Licence version 3.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext