time::mbc +linux +x86_64

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

// Undocumented 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[link]

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[link]

type invalid = !chrono::invalid;

Invalid datetime.

Constants

def EMAIL[link]

def EMAIL: str;

datetime::format layout for the email date format.

def EMAIL_Z[link]

def EMAIL_Z: str;

datetime::format layout for the email date format, with zone offset and zone abbreviation.

def EPOCHAL_MBC[link]

def EPOCHAL_MBC: i64;

The Hare epoch of the Martian Business Calendar.

def SOLS_CYCLE[link]

def SOLS_CYCLE: int;

The total number of sols in a 76-year cycle of the Martian Business Calendar.

def STAMP[link]

def STAMP: str;

datetime::format layout for a simple timestamp.

def STAMP_NANO[link]

def STAMP_NANO: str;

datetime::format layout for a simple timestamp with nanoseconds.

def STAMP_NOZL[link]

def STAMP_NOZL: str;

datetime::format layout for a simple timestamp with nanoseconds, zone offset, zone abbreviation, and locality.

def STELLAR[link]

def STELLAR: str;

datetime::format layout for a prosaic datetime, with the full month name, short weekday, and zone abbreviation.

def WKSTAMP[link]

def WKSTAMP: str;

datetime::format layout for a simple week-wise timestamp.

Functions

fn asformat[link]

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[link]

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[link]

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 from_instant[link]

fn from_instant(loc: chrono::locality, i: time::instant) datetime;

Creates a datetime from a time::instant in a time::chrono::locality.

fn from_moment[link]

fn from_moment(m: chrono::moment) datetime;

Creates a datetime from a time::chrono::moment.

fn hour[link]

fn hour(dt: *datetime) int;

Returns a datetime's hour of the sol.

fn in[link]

fn in(loc: chrono::locality, dt: datetime) datetime;

Creates an equivalent datetime with a different time::chrono::locality.

fn islongyear[link]

fn islongyear(y: int) bool;

Calculates whether a year is a long year.

fn minute[link]

fn minute(dt: *datetime) int;

Returns a datetime's minute of the hour.

fn month[link]

fn month(dt: *datetime) int;

Returns a datetime's month of the year.

fn nanosecond[link]

fn nanosecond(dt: *datetime) int;

Returns a datetime's nanosecond of the second.

fn new[link]

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 now[link]

fn now() datetime;

Returns a datetime of the current system time, using time::clock::REALTIME and time::chrono::LOCAL.

fn second[link]

fn second(dt: *datetime) int;

Returns a datetime's second of the minute.

fn sol[link]

fn sol(dt: *datetime) int;

Returns a datetime's sol of the month.

fn week[link]

fn week(dt: *datetime) int;

Returns a datetime's Gregorian week starting Monsol.

fn weeksol[link]

fn weeksol(dt: *datetime) int;

Returns a datetime's sol of the week.

fn year[link]

fn year(dt: *datetime) int;

Returns a datetime's year.

fn yearsol[link]

fn yearsol(dt: *datetime) int;

Returns a datetime's ordinal sol of the year.