ark-api-ffi 0.16.0

Ark low-level Wasm FFI API
Documentation
define_api_id!(0x6b95_7be8_9952_68be, "time-v1");

#[ark_api_macros::ark_bindgen(imports = "ark-time-v1")]
mod time {
    /// All of these time formats are local, except ISODateTimeUTC.
    #[repr(u32)]
    #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
    pub enum TimeFormat {
        /// "Yesterday", "A few seconds ago", etc.
        RelativeFriendly = 0,
        /// 1999
        Year = 1,
        /// July 1999 (or local variants)
        YearMonth = 2,
        /// July 5, 1999 (or local variants)
        Date = 3,
        /// 14:43 (or 2:43 PM, locale dependent)
        HourMinute = 4,
        /// 14:43:45 (or 2:43 PM, locale dependent)
        HourMinuteSecond = 5,
        /// Local timezone ISO 8601 date: 1996-12-19
        ISODate = 7,
        /// Local timezone ISO 8601 date and time string: 1996-12-19T16:39:57-08:00
        ISODateTime = 8,
        /// UTC timezone ISO 8601 date and time string: 1996-12-19T16:39:57Z
        ISODateTimeUTC = 9,
    }

    extern "C" {
        /// Gets the current time as nanoseconds since the UNIX epoch.
        pub fn time_utc() -> i64;

        pub fn format_time_for_display(ns_since_epoch: i64, time_format: TimeFormat) -> String;
    }
}

pub use time::*;