time::mbc
The time::mbc module implements the Martian-time "MBC" chronology based
upon the proposed Martian Business Calendar system by Bruce Mills, and
the common 24-hour clock. This module assumes the stdlib's
time::chrono::mtc timescale and time::chrono::MTC locality.
Index
Types
type datetime;
Errors
type invalid;
Constants
const EMAIL: str;
const EMAIL_Z: str;
const EPOCHAL_MBC: i64;
const SOLS_CYCLE: int;
const STAMP: str;
const STAMP_NANO: str;
const STAMP_NOZL: str;
const STELLAR: str;
const WKSTAMP: str;
Functions
fn asformat(str, *datetime) (str | invalid | io::error);
fn bsformat([]u8, str, *datetime) (str | invalid | io::error);
fn format(io::handle, str, *datetime) (size | invalid | io::error);
fn from_instant(chrono::locality, time::instant) datetime;
fn from_moment(chrono::moment) datetime;
fn hour(*datetime) int;
fn in(chrono::locality, datetime) datetime;
fn islongyear(int) bool;
fn minute(*datetime) int;
fn month(*datetime) int;
fn nanosecond(*datetime) int;
fn new(chrono::locality, time::duration, int...) (datetime | invalid);
fn now() datetime;
fn second(*datetime) int;
fn sol(*datetime) int;
fn week(*datetime) int;
fn weeksol(*datetime) int;
fn year(*datetime) int;
fn yearsol(*datetime) int;
Types
type datetime
Show undocumented member
type datetime = struct {
chrono::moment,
year: (void | int),
month: (void | int),
sol: (void | int),
yearsol: (void | int),
week: (void | int),
weeksol: (void | int),
hour: (void | int),
minute: (void | int),
second: (void | int),
nanosecond: (void | int),
};
Errors
type invalid
type invalid = !chrono::invalid;
Invalid datetime.
Constants
def EMAIL_Z
def EMAIL_Z: str;
datetime::format layout for the email date format,
with zone offset and zone abbreviation.
def EPOCHAL_MBC
def EPOCHAL_MBC: i64;
The Hare epoch of the Martian Business Calendar.
def SOLS_CYCLE
def SOLS_CYCLE: int;
The total number of sols in a 76-year cycle of the Martian Business Calendar.
def STAMP_NANO
def STAMP_NANO: str;
datetime::format layout for a simple timestamp with nanoseconds.
def STAMP_NOZL
def STAMP_NOZL: str;
datetime::format layout for a simple timestamp with nanoseconds,
zone offset, zone abbreviation, and locality.
def STELLAR
def STELLAR: str;
datetime::format layout for a prosaic datetime,
with the full month name, short weekday, and zone abbreviation.
def WKSTAMP
def WKSTAMP: str;
datetime::format layout for a simple week-wise timestamp.
Functions
fn asformat(layout: str, dt: *datetime) (str | invalid | io::error);
Formats a datetime and writes it into a heap-allocated string.
The caller must free the return value.
fn bsformat(buf: []u8, layout: str, dt: *datetime) (str | invalid | io::error);
Formats a datetime and writes it into a caller supplied buffer.
The returned string is borrowed from this buffer.
fn format(h: io::handle, layout: str, dt: *datetime) (size | invalid | io::error);
Formats a datetime according to a layout and writes to an io::handle.
The layout may contain any of the following format specifiers listed below.
Implemented are a subset of the POSIX strftime(3) format specifiers, as well
as some others. Use of unimplemented specifiers or an otherwise invalid
layout will cause an abort.
%% -- A literal '%' character.
%a -- The abbreviated name of the sol of the week.
%A -- The full name of the sol of the week.
%b -- The abbreviated name of the month.
%B -- The full name of the month.
%d -- The sol of the month (decimal, range 01 to 31).
%H -- The hour of the sol as from a 24-hour clock (range 00 to 23).
%j -- The ordinal sol of the year (range 001 to 366).
%L -- The locality's name (the timezone's identifier).
%m -- The month (decimal, range 01 to 12).
%M -- The minute (decimal, range 00 to 59).
%N -- The nanosecond of the second (range 000000000 to 999999999).
%S -- The second of the minute (range 00 to 60).
%u -- The sol of the week (decimal, range 1 to 7). 1 represents Monday.
%W -- The week number of the current year (range 00 to 53).
%y -- The year without the century digits (range 00 to 99).
%Y -- The year.
%z -- The observed zone offset.
%Z -- The observed zone abbreviation.
fn hour
fn hour(dt: *datetime) int;
Returns a datetime's hour of the sol.
fn islongyear
fn islongyear(y: int) bool;
Calculates whether a year is a long year.
fn minute
fn minute(dt: *datetime) int;
Returns a datetime's minute of the hour.
fn month
fn month(dt: *datetime) int;
Returns a datetime's month of the year.
fn nanosecond
fn nanosecond(dt: *datetime) int;
Returns a datetime's nanosecond of the second.
fn new
fn new(
loc: chrono::locality,
zo: time::duration,
fields: int...
) (datetime | invalid);
Creates a new MBC datetime.
// 0000 Sgtr 1st 00:00:00.000000000 +0000 MTC
mbc::new(time::chrono::MTC, 0);
// 0262 Vrig 23rd 23:59:39.522000000 +0000 MTC
mbc::new(time::chrono::MTC, 0, 0262, 19, 23, 23, 59, 39, 522000000);
fn second
fn second(dt: *datetime) int;
Returns a datetime's second of the minute.
fn sol
fn sol(dt: *datetime) int;
Returns a datetime's sol of the month.
fn week
fn week(dt: *datetime) int;
Returns a datetime's Gregorian week starting Monsol.
fn weeksol
fn weeksol(dt: *datetime) int;
Returns a datetime's sol of the week.
fn year
fn year(dt: *datetime) int;
Returns a datetime's year.
fn yearsol
fn yearsol(dt: *datetime) int;
Returns a datetime's ordinal sol of the year.