bit_date

Git date parsing primitives (gix-date equivalent)

git
date
rfc2822
moon add mizchi/bit_date@0.46.4
Download zip
Author
Version
0.46.4
License
Apache-2.0
Last updated
4 days ago
Downloads
497
README

#
date_is_leap_year

fn date_is_leap_year(year : Int) -> Bool

Check if a year is a leap year.

#
days_since_epoch

fn days_since_epoch(year : Int, month : Int, day : Int) -> Int

Calculate the number of days since the Unix epoch (1970-01-01).

#
month_name_to_number

fn month_name_to_number(name : String) -> Int?

Convert a month name (e.g. "jan", "february") to its number (1-12).

#
parse_approxidate

fn parse_approxidate(date_str : String, now : Int64) -> Int64?

Parse a date string trying multiple formats: ISO 8601, relative, human-readable, YYYY-MM-DD. Takes the current timestamp for relative date resolution.

#
parse_approxidate_epoch

fn parse_approxidate_epoch(s : String) -> Int64?

Parse git's raw epoch date form @<seconds>, optionally followed by a timezone such as +0000. The timezone offset does not change the epoch value git reports, so it is accepted but ignored. Returns None when the string is not in this form.

#
parse_approxidate_human

fn parse_approxidate_human(s : String) -> Int64?

Parse a human-readable date string like "Jan 15 2024" or "January 15 2024 10:30:00".

#
parse_approxidate_iso8601

fn parse_approxidate_iso8601(s : String) -> Int64

Parse an ISO 8601 date/time string (e.g. "2024-01-15T10:30:00"). Returns 0 if the string is too short or if the resulting calendar fields are out of range (would index month_days[] out of bounds inside days_since_epoch).

#
parse_approxidate_iso_date

fn parse_approxidate_iso_date(s : String) -> Int64?

Parse a YYYY-MM-DD date string, optionally with time (YYYY-MM-DD HH:MM:SS or YYYY-MM-DDTHH:MM:SS).

#
parse_approxidate_relative

fn parse_approxidate_relative(s : String, now : Int64) -> Int64?

Parse a relative date string like "2 weeks ago", "yesterday", "now". Takes the current timestamp as a parameter for purity.

#
parse_date_digits

fn parse_date_digits(chars : Array[Char], start : Int, end : Int) -> Int

Parse digits from a character array between start (inclusive) and end (exclusive).

#
parse_int_from_string

fn parse_int_from_string(s : String) -> Int

Parse a leading integer from a string, stopping at the first non-digit.

Source Files

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io