birl/time

Types

Deprecated: Use birl.Day instead!

@deprecated("Use birl.Day instead!")
pub type Date {
  Date(year: Int, month: Int, day: Int)
}

Constructors

  • Date(year: Int, month: Int, day: Int)

Deprecated: Use birl.Time instead!

pub opaque type DateTime

Deprecated: Use birl.Month instead!

@deprecated("Use birl.Month instead!")
pub type Month {
  Jan
  Feb
  Mar
  Apr
  May
  Jun
  Jul
  Aug
  Sep
  Oct
  Nov
  Dec
}

Constructors

  • Jan
  • Feb
  • Mar
  • Apr
  • May
  • Jun
  • Jul
  • Aug
  • Sep
  • Oct
  • Nov
  • Dec

Deprecated: Use birl.TimeOfDay instead!

@deprecated("Use birl.TimeOfDay instead!")
pub type Time {
  Time(hour: Int, minute: Int, second: Int, milli_second: Int)
}

Constructors

  • Time(hour: Int, minute: Int, second: Int, milli_second: Int)

Deprecated: Use birl.Weekday instead!

@deprecated("Use birl.Weekday instead!")
pub type Weekday {
  Mon
  Tue
  Wed
  Thu
  Fri
  Sat
  Sun
}

Constructors

  • Mon
  • Tue
  • Wed
  • Thu
  • Fri
  • Sat
  • Sun

Constants

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

starting point of unix timestamps

Functions

pub fn add(value: DateTime, duration: Duration) -> DateTime

Deprecated: Use birl.add instead!

pub fn compare(a: DateTime, b: DateTime) -> Order

Deprecated: Use birl.compare instead!

pub fn difference(a: DateTime, b: DateTime) -> Duration

Deprecated: Use birl.difference instead!

pub fn from_erlang_local_datetime(
  erlang_datetime: #(#(Int, Int, Int), #(Int, Int, Int)),
) -> DateTime

Deprecated: Use birl.from_erlang_local_time instead!

calculates the DateTime value from the erlang datetime using the local offset of the system

pub fn from_erlang_universal_datetime(
  erlang_datetime: #(#(Int, Int, Int), #(Int, Int, Int)),
) -> DateTime

Deprecated: Use birl.from_erlang_universal_time instead!

calculates the DateTime value from the erlang datetime in UTC

pub fn from_http(value: String) -> Result(DateTime, Nil)

Deprecated: Use birl.from_http instead!

see here

also supports other similar formats:

  • Tue, 01-Nov-2016 08:49:37 GMT

  • Tue, 01 Nov 2016 08:49:37 +0630

  • Tue, 01-November-2016 08:49:37 Z

  • Tuesday, 01-Nov-2016 08:49:37 +330

  • Tuesday, 01 November 2016 08:49:37 +06:30

pub fn from_iso8601(value: String) -> Result(DateTime, Nil)

Deprecated: Use birl.parse instead!

pub fn from_naive(value: String) -> Result(DateTime, Nil)

Deprecated: Use birl.from_naive instead!

the naive format is the same as ISO8601 except that it does not contain the offset

pub fn from_unix(value: Int) -> DateTime

Deprecated: Use birl.from_unix instead!

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

pub fn get_date(value: DateTime) -> Date

Deprecated: Use birl.get_date instead!

pub fn get_offset(value: DateTime) -> String

Deprecated: Use birl.get_offset instead!

pub fn get_time(value: DateTime) -> Time

Deprecated: Use birl.get_time_of_day instead!

pub fn get_timezone(value: DateTime) -> Option(String)

Deprecated: Use birl.get_timezone instead!

pub fn legible_difference(a: DateTime, b: DateTime) -> String

Deprecated: Use birl.legible_difference instead!

pub fn monotonic_now() -> Int

Deprecated: Use birl.monotonic_now instead!

pub fn month(value: DateTime) -> Month

Deprecated: Use birl.month instead!

pub fn now() -> DateTime

Deprecated: Use birl.now instead!

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

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

Deprecated: Use birl.now_with_offset instead!

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 now_with_timezone(
  timezone: String,
) -> Result(DateTime, Nil)

Deprecated: Use birl.now_with_timezone instead!

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

Deprecated: Use birl.range instead!

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: DateTime, date: Date) -> DateTime

Deprecated: Use birl.set_date instead!

pub fn set_offset(
  value: DateTime,
  new_offset: String,
) -> Result(DateTime, Nil)

Deprecated: Use birl.set_offset instead!

use this to 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: DateTime, time: Time) -> DateTime

Deprecated: Use birl.set_time_of_day instead!

pub fn set_timezone(
  value: DateTime,
  new_timezone: String,
) -> Result(DateTime, Nil)

Deprecated: Use birl.set_timezone instead!

pub fn short_string_month(value: DateTime) -> String

Deprecated: Use birl.short_string_month instead!

pub fn short_string_weekday(value: DateTime) -> String

Deprecated: Use birl.short_string_weekday instead!

pub fn string_month(value: DateTime) -> String

Deprecated: Use birl.string_month instead!

pub fn string_weekday(value: DateTime) -> String

Deprecated: Use birl.string_weekday instead!

pub fn subtract(value: DateTime, duration: Duration) -> DateTime

Deprecated: Use birl.subtract instead!

pub fn to_erlang_datetime(
  value: DateTime,
) -> #(#(Int, Int, Int), #(Int, Int, Int))

Deprecated: Use birl.to_erlang_time instead!

calculates erlang datetime using the offset in the DateTime value

pub fn to_erlang_universal_datetime(
  value: DateTime,
) -> #(#(Int, Int, Int), #(Int, Int, Int))

Deprecated: Use birl.to_erlang_universal_time instead!

calculates the universal erlang datetime regardless of the offset in the DateTime value

pub fn to_http(value: DateTime) -> String

Deprecated: Use birl.to_http instead!

see here

pub fn to_http_with_offset(value: DateTime) -> String

Deprecated: Use birl.to_http_with_offset instead!

like to_http but assumes the offset in the DateTime value instead of GMT

pub fn to_iso8601(value: DateTime) -> String

Deprecated: Use birl.to_iso8601 instead!

pub fn to_naive(value: DateTime) -> String

Deprecated: Use birl.to_naive instead!

the naive format is the same as ISO8601 except that it does not contain the offset

pub fn to_unix(value: DateTime) -> Int

Deprecated: Use birl.to_unix instead!

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

pub fn utc_now() -> DateTime

Deprecated: Use birl.utc_now instead!

Use this to get the current time in utc

pub fn weekday(value: DateTime) -> Weekday

Deprecated: Use birl.weekday instead!

Search Document