1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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::*;