birl/time

Types

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,
)
pub fn compare(a: Time, b: Time) -> Order
pub fn difference(a: Time, b: Time) -> Duration
pub fn from_iso8601(value: String) -> Result(Time, Nil)
pub fn from_parts(date: #(Int, Int, Int), time: #(
    Int,
    Int,
    Int,
    Int,
  ), offset offset: String) -> Result(Time, Nil)
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 the get the current time with a given offset.

Some examples of acceptable offsets:

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

pub fn subtract(value: Time, duration: Duration) -> Time
pub fn to_iso8601(value: Time) -> String
pub fn to_parts(value: Time) -> #(
  #(Int, Int, Int),
  #(Int, Int, Int, Int),
  String,
)
pub fn utc_now() -> Time

use this to get the current time in utc

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