Next: srfi.27
- Sources of Random Bits, Previous: srfi.13
- String library, Up: Library modules - SRFIs [Contents][Index]
srfi.19
- Time data types and proceduresThis SRFI defines various representations of time and date, and conversion methods among them.
On Gauche, time object is supported natively by <time>
class
(see Time). Date object is supported by <date>
class
described below.
• SRFI-19 Time types: | ||
• SRFI-19 Time queries: | ||
• SRFI-19 Time procedures: | ||
• SRFI-19 Date: | ||
• SRFI-19 Date reader and writer: |
Next: Time queries, Previous: srfi.19
- Time data types and procedures, Up: srfi.19
- Time data types and procedures [Contents][Index]
Time type is represented by a symbol. This module defines the following constant variables that is bound to its name, for convenience.
[SRFI-19]{srfi.19}
UTC time. Gauche’s built-in current-time
always returns
this type (see Time).
[SRFI-19]{srfi.19} International Atomic Time. This time is a bit larger than UTC, due to the leap seconds.
[SRFI-19]{srfi.19}
Implementation-dependent monotonically increasing time.
In Gauche, this is the same as time-tai
.
[SRFI-19]{srfi.19} Duration between two absolute time points.
[SRFI-19]{srfi.19} CPU time in current process. Gauche calculates this from user time and system time returned by POSIX times(3).
[SRFI-19]{srfi.19}
CPU time in current thread.
In the current implementation, this is the same as time-process
.
Next: Time procedures, Previous: Time types, Up: srfi.19
- Time data types and procedures [Contents][Index]
[SRFI-19]{srfi.19}
Extends Gauche built-in current-time
(see Time) to take
optional time-type argument to specify the desired time type.
time-type must be one of the types described in Time types.
[SRFI-19]{srfi.19}
Returns the current date as an instance of <date>
class
(see Date). If tz-offset is given, it must be
an offset from UTC in number of seconds. If tz-offset is
not given, returns the date in local time zone.
[SRFI-19]{srfi.19} Returns the current julian day, a point in time as a real number of days since -4714-11-24T12:00:00Z (November 24, -4714 at noon, UTC).
[SRFI-19]{srfi.19} Returns the current modified julian day, a point in time as a real number of days since 1858-11-17T00:00:00Z (November 17, 1858 at midnight, UTC).
[SRFI-19]{srfi.19}
Returns clock resolution of the time type type in nanoseconds,
as an exact positive integer. If type is omitted, time-utc
is assumed.
Note: In the current implementation, the return value isn’t actual resolution, but a value that’s guaranteed to be equal to or greater than the actual resolution.
Next: Date, Previous: Time queries, Up: srfi.19
- Time data types and procedures [Contents][Index]
[SRFI-19]{srfi.19}
Returns an instance of <time>
class with specified initial values.
Equivalent to (make <time> :type type :second seconds :nanosecond nanoseconds)
.
[SRFI-19]{srfi.19}
Getter and setter of <time>
object slots.
[SRFI-19]{srfi.19}
Returns a new instance of <time>
whose content is the same as
given time
[SRFI-19]{srfi.19} Compares two times. Types of both times must match.
[SRFI-19]{srfi.19}
Returns the difference of two times, in time-duration
time.
Types of both times must match.
Time-difference!
modifies time0 to store the result.
[SRFI-19]{srfi.19}
Adds or subtracts time-duration to or from time0.
Type of returned time is the same as time0. Type of
time-duration must be time-duration
.
add-duration!
and subtract-duration!
reuse
time0 to store the result.
See also seconds+
(Time).
Next: Date reader and writer, Previous: Time procedures, Up: srfi.19
- Time data types and procedures [Contents][Index]
{srfi.19} Represents a date.
Nanosecond portion of the date by an integer between 0 and 999,999,999, inclusive.
Second portion of the date by an integer between 0 and 60, inclusive. (60 for leap second).
Minute portion of the date by an integer between 0 and 59, inclusive.
Hour portion of the date by an integer between 0 and 23, inclusive.
Day portion of the date by an integer between 0 and 31, inclusive. The actual upper bound of the day is determined by the year and the month. (Note: 1 is for the first day; 0 is allowed by the specification, but I don’t see why).
Month portion of the date by an integer between 1 and 12, inclusive.
1 for January, 2 for February, and so on.
(Note: this is different from POSIX’s <sys-tm>
convention).
Year portion of the date.
The number of seconds east of GMT for this timezone, by an integer.
[SRFI-19]{srfi.19}
Makes a <date>
object from the given values.
Note: this procedure does not check if the values are in the valid range.
[SRFI-19]{srfi.19}
Returns true iff obj is a <date>
object.
[SRFI-19]{srfi.19} Accessors.
[SRFI-19]{srfi.19} Calculates the day number in the year (1 for January 1st), the day number in the week (0 for Sunday, 1 for Monday, ...), and the ordinal week of the year which holds this date, ignoring a first partial week, respectively.
Day-of-week-starting-week is the integer corresponding to the day of the week which is to be considered the first day of the week (Sunday=0, Monday=1, etc.).
[SRFI-19]{srfi.19} Conversions from date to various date/time types.
[SRFI-19]{srfi.19} Conversions from julian-day to various date/time types.
[SRFI-19]{srfi.19} Conversions from modified julian-day to various date/time types.
[SRFI-19]{srfi.19} Conversions from time-monotonic to various date/time types.
[SRFI-19]{srfi.19} Conversions from time-tai to various date/time types.
[SRFI-19]{srfi.19} Conversions from time-utc to various date/time types.
Previous: Date, Up: srfi.19
- Time data types and procedures [Contents][Index]
[SRFI-19+]{srfi.19}
Converts a <date>
object to a string, according
to the format specified by format-string.
If format-string is omitted, "~c"
is assumed.
A format string is copied to output, except a sequence begins with
~
which is replaced with the following rules:
~~
A literal ~
.
~a
Locale’s abbreviated weekday name (Sun...Sat).
~A
Locale’s full weekday name (Sunday...Saturday).
~b
Locale’s abbreviate month name (Jan...Dec).
~B
Locale’s full month name (January...December).
~c
Locale’s date and time (e.g., "Fri Jul 14 20:28:42-0400 2000"
).
~d
Day of month, zero padded (01...31).
~D
Date (mm/dd/yy).
~e
Day of month, blank padded ( 1...31).
~f
Seconds+fractional seconds, using locale’s decimal separator (e.g. 5.2).
~h
Same as ~b
.
~H
Hour, zero padded, 24-hour clock (00...23).
~I
Hour, zero padded, 12-hour clock (01...12).
~j
Day of year, zero padded.
~k
Hour, blank padded, 24-hour clock ( 0...23).
~l
Hour, blank padded, 12-hour clock ( 1...12).
~m
Month, zero padded (01...12).
~M
Minute, zero padded (00...59).
~n
New line.
~N
Nanosecond, zero padded.
~p
Locale’s AM or PM.
~r
Time, 12 hour clock, same as "~I:~M:~S ~p"
.
~s
Number of full seconds since "the epoch" (in UTC).
~S
Second, zero padded (00...60).
~t
Horizontal tab.
~T
Time, 24 hour clock, same as "~H:~M:~S"
.
~U
Week number of year with Sunday as first day of week (00...53).
~V
ISO8601 Week number of year with Monday as first day of week. The week with the first Thursday is week 01. If there’s a partial week before that, it becomes week 52 or 53 of the preceding year (01...53).
~w
Day of week (0...6).
~W
Week number of year with Monday as first day of week (00...52).
~x
Locale’s date representation, for example: "07/31/00"
.
~X
Locale’s time representation, for example: "06:51:44"
.
~y
Last two digits of year (00...99).
~Y
Year.
~z
Time zone in RFC-822 style.
~1
ISO-8601 year-month-day format, e.g. "2001-02-03"
.
~2
ISO-8601 hour-minute-second-timezone format, e.g. "04:56:12-1000"
.
~3
ISO-8601 hour-minute-second format, e.g. "04:56:12"
.
~4
ISO-8601 year-month-day-hour-minute-second-timezone format,
e.g. "2001-02-03T04:56:12-1000"
.
~5
ISO-8601 year-month-day-hour-minute-second format,
e.g. "2001-02-03T04:56:12"
.
Note: currently Gauche doesn’t honor process’s locale setting,
and it always formats the date as if the locale is "C". It may
be changed in future, so you shouldn’t rely on, for example,
~a
always formatted as "Sun".."Sat".
There’s no portable way to ensure you’ll get "C" locale formats
since there’s no standard way to set process’s locale yet.
However, Gauche provides a way to ensure the locale to be "C",
as an extension to srfi-19.
Insert @
between ~
and the directive
character, such as ~@a
.
[SRFI-19]{srfi.19}
Next: srfi.27
- Sources of Random Bits, Previous: srfi.13
- String library, Up: Library modules - SRFIs [Contents][Index]