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

Functions

pub fn add(value: Time, duration: Duration) -> Time
pub fn change_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"

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_parts(date: #(Int, Int, Int), time: #(
    Int,
    Int,
    Int,
    Int,
  ), offset: 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 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(a: Time, b: Time, s: Duration) -> Iterator(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_parts(value: Time) -> #(
  #(Int, Int, Int),
  #(Int, Int, Int, Int),
  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