birl/time

Types

pub type Month {
  January
  February
  March
  April
  May
  June
  July
  August
  September
  October
  November
  December
}

Constructors

  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
pub opaque type Time
pub type Weekday {
  Monday
  Tuesday
  Wednesday
  Thursday
  Friday
  Saturday
  Sunday
}

Constructors

  • Monday
  • Tuesday
  • Wednesday
  • Thursday
  • Friday
  • Saturday
  • Sunday

Constants

pub const unix_epoch: Time = Time(0, 0, option.None)

starting point of unix timestamps

Functions

pub fn add(value: Time, duration: Duration) -> Time
pub fn compare(a: Time, b: Time) -> Order
pub fn difference(a: Time, b: Time) -> Duration
pub fn from_http(value: String) -> Result(Time, Nil)

see here

pub fn from_iso8601(value: String) -> Result(Time, Nil)
pub fn from_unix(value: Int) -> Time

unix timestamps are the number of seconds that have elapsed since 00:00:00 UTC on January 1st, 1970

pub fn get_date(value: Time) -> #(Int, Int, Int)
pub fn get_offset(value: Time) -> String
pub fn get_time(value: Time) -> #(Int, Int, Int, Int)
pub fn month(value: Time) -> Month
pub fn now() -> Time

use this to get the current time in the local timezone offset

pub fn now_with_offset(offset: String) -> Result(Time, Nil)

use this to get the current time with a given offset.

Some examples of acceptable offsets:

"+330", "03:30", "-8:00","-7", "-0400", "03"

pub fn range(from a: Time, to b: Option(Time), step s: Duration) -> Iterator(
  Time,
)

can be used to create a time range starting from time a with step s

if b is option.None the range will be infinite

pub fn set_date(value: Time, new_date: #(Int, Int, Int)) -> Time
pub fn set_offset(value: Time, new_offset: String) -> Result(
  Time,
  Nil,
)

use this tp change the offset of a given time value.

Some examples of acceptable offsets:

"+330", "03:30", "-8:00","-7", "-0400", "03", "Z"

pub fn set_time(value: Time, new_time: #(Int, Int, Int, Int)) -> Time
pub fn short_string_month(value: Time) -> String
pub fn short_string_weekday(value: Time) -> String
pub fn string_month(value: Time) -> String
pub fn string_weekday(value: Time) -> String
pub fn subtract(value: Time, duration: Duration) -> Time
pub fn to_http(value: Time) -> String

see here

pub fn to_iso8601(value: Time) -> String
pub fn to_unix(value: Time) -> Int

unix timestamps are the number of seconds that have elapsed since 00:00:00 UTC on January 1st, 1970

pub fn utc_now() -> Time

use this to get the current time in utc

pub fn weekday(value: Time) -> Weekday
Search Document