Module z_datetime

Utility functions for datetime handling and representation.

Copyright © 2009-2016 Marc Worrell

Authors: Marc Worrell (marc@worrell.nl).

Description

Utility functions for datetime handling and representation.

Data Types

ldom()

ldom() = 28 | 29 | 30 | 31

month()

month() = 1..12

year()

year() = integer()

Function Index

datetime_to_timestamp/1Translate a local time date to UNIX timestamp.
days_in_year/1Return the number of days in a certain year.
diff/2Return the absolute difference between two dates.
format/2Format the current date according to the format and the timezone settings in the context.
format/3Format a date according to the format and the timezone settings in the context.
format_utc/2Format the current date in UTC.
format_utc/3Format the date using the UTC timezone.
is_leap_year/1
last_day_of_the_month/2
month_boundaries/1Return the month-boundaries of a given date.
next_day/1Return the date one day later.
next_hour/1Return the date one hour later.
next_minute/1Return the date one minute later.
next_month/1Return the date one month later.
next_second/1Return the date one second later.
next_week/1Return the date one week later.
next_year/1Return the date one year later.
prev_day/1Return the date one day earlier.
prev_hour/1Return the date one hour earlier.
prev_minute/1Return the date one minute earlier.
prev_month/1Return the date one month earlier.
prev_second/1Return the date one second earlier.
prev_week/1Return the date one week earlier.
prev_year/1Return the date one year earlier.
timesince/2Show a humanized version of a relative datetime.
timesince/3Show a humanized version of a period between two dates.
timesince/4
timesince/5Show a humanized version of a period between two dates.
timestamp/0Calculate the current UNIX timestamp (seconds since Jan 1, 1970).
timestamp_to_datetime/1Translate UNIX timestamp to local datetime.
to_datetime/1Convert an input to a (universal) datetime, using to_date/1 and to_time/1.
to_datetime/2
to_local/2Convert a time to the local context time using the current timezone.
to_utc/2Convert a time to the local context time using the current timezone.
undefined_if_invalid_date/1Return 'undefined' if a given date is invalid.
week_boundaries/1Return the week-boundaries of a given date.
week_boundaries/2
week_start/0Return the date the current week starts (monday).
week_start/2

Function Details

datetime_to_timestamp/1

datetime_to_timestamp(DT) -> any()

Translate a local time date to UNIX timestamp

days_in_year/1

days_in_year(Y) -> any()

Return the number of days in a certain year.

diff/2

diff(Date1, Date2) -> any()

Return the absolute difference between two dates. Does not take daylight saving into account.

format/2

format(Format, Context) -> any()

Format the current date according to the format and the timezone settings in the context.

format/3

format(Date, Format, Context) -> any()

Format a date according to the format and the timezone settings in the context.

format_utc/2

format_utc(Format, Context) -> any()

Format the current date in UTC.

format_utc/3

format_utc(Date, Format, Context) -> any()

Format the date using the UTC timezone.

is_leap_year/1

is_leap_year(Year) -> boolean()

last_day_of_the_month/2

last_day_of_the_month(Year, Month) -> LastDay

month_boundaries/1

month_boundaries(X1) -> any()

Return the month-boundaries of a given date

next_day/1

next_day(Date) -> any()

Return the date one day later.

next_hour/1

next_hour(Date) -> any()

Return the date one hour later.

next_minute/1

next_minute(Date) -> any()

Return the date one minute later.

next_month/1

next_month(X1) -> any()

Return the date one month later. Gives unpredictable results if the day doesn't exist in the next month. (eg. feb 30 will become feb 28).

next_second/1

next_second(Date) -> any()

Return the date one second later.

next_week/1

next_week(DT) -> any()

Return the date one week later.

next_year/1

next_year(X1) -> any()

Return the date one year later.

prev_day/1

prev_day(Date) -> any()

Return the date one day earlier.

prev_hour/1

prev_hour(Date) -> any()

Return the date one hour earlier.

prev_minute/1

prev_minute(Date) -> any()

Return the date one minute earlier.

prev_month/1

prev_month(X1) -> any()

Return the date one month earlier.

prev_second/1

prev_second(Date) -> any()

Return the date one second earlier.

prev_week/1

prev_week(DT) -> any()

Return the date one week earlier.

prev_year/1

prev_year(X1) -> any()

Return the date one year earlier.

timesince/2

timesince(Date, Context) -> string()

Show a humanized version of a relative datetime. Like "4 months, 3 days ago".

timesince/3

timesince(Date, Base::BaseDate, Context) -> string()

Show a humanized version of a period between two dates. Like "4 months, 3 days ago".

timesince/4

timesince(Date, Base, IndicatorStrings, Context) -> any()

timesince/5

timesince(Date, Base::BaseDate, IndicatorStrings, Mode, Context) -> string()

Show a humanized version of a period between two dates. Like "4 months, 3 days ago". WhenText is a string containing a maximum of three tokens. Example "ago, now, in"

timestamp/0

timestamp() -> any()

Calculate the current UNIX timestamp (seconds since Jan 1, 1970)

timestamp_to_datetime/1

timestamp_to_datetime(Seconds) -> any()

Translate UNIX timestamp to local datetime.

to_datetime/1

to_datetime(Input) -> calendar:datetime()

Convert an input to a (universal) datetime, using to_date/1 and to_time/1. When the input is a string, it is expected to be in iso 8601 format, although it can also handle timestamps without time zones. The time component of the datetime is optional.

to_datetime/2

to_datetime(DT, Tz) -> any()

to_local/2

to_local(Date::calendar:datetime() | undefined | time_not_exists, Tz::string() | binary() | z:context()) -> calendar:datetime() | undefined

Convert a time to the local context time using the current timezone.

to_utc/2

to_utc(Date::calendar:datetime() | undefined | time_not_exists, Tz::string() | binary() | z:context()) -> calendar:datetime() | undefined

Convert a time to the local context time using the current timezone.

undefined_if_invalid_date/1

undefined_if_invalid_date(Date) -> any()

Return 'undefined' if a given date is invalid

week_boundaries/1

week_boundaries(Date) -> any()

Return the week-boundaries of a given date. WeekStart is optional, and determines on which day a week starts.

week_boundaries/2

week_boundaries(Date, WeekStart) -> any()

week_start/0

week_start() -> any()

Return the date the current week starts (monday)

week_start/2

week_start(StartDayNr, X2) -> any()


Generated by EDoc