z_datetime (zotonic_core v1.0.0-rc.11)
Link to this section Summary
Functions
Translate a local time date to UNIX timestamp
Return the number of days in a certain year.
Return the absolute difference between two dates. Does not take daylight saving into account.
Format the current date according to the format and the timezone settings in the context.
Format a date according to the format and the timezone settings in the context.
Format the current date in UTC.
Format the date using the UTC timezone.
Shift a date if the date falls outside the valid date or time ranges. Return undefined if the date could not be mapped to some valid date.
Return the month-boundaries of a given date
Return the date one day later.
Return the date one hour later.
Return the date one minute later.
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).
Return the date one second later.
Return the date one week later.
Return the date one year later.
Return the date one day earlier.
Return the date one hour earlier.
Return the date one minute earlier.
Return the date one month earlier.
Return the date one second earlier.
Return the date one week earlier.
Return the date one year earlier.
Show a humanized version of a relative datetime. Like "4 months, 3 days ago".
Show a humanized version of a period between two dates. Like "4 months, 3 days ago".
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"Calculate the current UNIX timestamp (seconds since Jan 1, 1970)
Translate UNIX timestamp to local 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.
Convert a time to the local context time using the current timezone.
Convert a time to the local context time using the current timezone.
Return 'undefined' if a given date is invalid
Return the week-boundaries of a given date. WeekStart is optional, and determines on which day a week starts.
Return the date the current week starts (monday)
Link to this section Types
Link to this type
date/0
-type date() :: calendar:date() | {integer(), 1..12, 1..31}.
Link to this type
datetime/0
-type datetime() :: calendar:datetime() | {{integer(), 1..12, 1..31}, {0..23, 0..59, 0..59}}.
Link to this type
fixable_datetime/0
Link to this type
ldom/0
-type ldom() :: 28 | 29 | 30 | 31.
Link to this type
month/0
-type month() :: 1..12.
Link to this type
year/0
-type year() :: integer().
Link to this section Functions
Link to this function
datetime_to_timestamp(DT)
Link to this function
days_in_year(Y)
Link to this function
diff(Date1, Date2)
Link to this function
format(Format, Context)
Link to this function
format(Date, Format, Context)
Link to this function
format_utc(Format, Context)
Link to this function
format_utc(Date, Format, Context)
Link to this function
is_leap_year(Year)
-spec is_leap_year(Year) -> boolean() when Year :: year().
Link to this function
last_day_of_the_month(Year, Month)
Link to this function
maybe_fix_datetime(Date)
-spec maybe_fix_datetime(fixable_datetime() | undefined) -> datetime() | undefined.
Link to this function
month_boundaries(_)
Link to this function
next_day(Date)
Link to this function
next_day(Date, N)
Link to this function
next_hour(Date)
Link to this function
next_hour(Date, N)
Link to this function
next_minute(Date)
Link to this function
next_minute(Date, N)
Link to this function
next_month(DT)
Link to this function
next_month(Date, N)
Link to this function
next_second(Date)
Link to this function
next_second(Date, N)
Link to this function
next_week(DT)
Link to this function
next_week(Date, N)
Link to this function
next_year(Date)
Link to this function
next_year(Date, N)
Link to this function
prev_day(Date)
Link to this function
prev_day(Date, N)
Link to this function
prev_hour(Date)
Link to this function
prev_hour(Date, N)
Link to this function
prev_minute(Date)
Link to this function
prev_minute(Date, N)
Link to this function
prev_month(DT)
Link to this function
prev_month(DT, N)
Link to this function
prev_second(Date)
Link to this function
prev_second(Date, N)
Link to this function
prev_week(DT)
Link to this function
prev_week(Date, N)
Link to this function
prev_year(Date)
Link to this function
prev_year(Date, N)
Link to this function
timesince(Date, Context)
Link to this function
timesince(Date, Base, Context)
Link to this function
timesince(Date, Base, IndicatorStrings, Context)
Link to this function
timesince(Date, Base, IndicatorStrings, Mode, Context)
WhenText
is a string containing a maximum of three tokens. Example "ago, now, in"
Link to this function
timestamp()
Link to this function
timestamp_to_datetime(Seconds)
Link to this function
to_datetime(Input)
-spec to_datetime(Input) -> calendar:datetime() when Input :: undefined | binary() | string() | integer() | calendar:datetime() | {Y :: integer(), M :: pos_integer(), D :: pos_integer()}.
Link to this function
to_datetime(DT, Tz)
Link to this function
to_local(Date, Tz)
-spec to_local(calendar:datetime() | undefined | time_not_exists, string() | binary() | z:context()) -> calendar:datetime() | undefined.
Link to this function
to_utc(Date, Tz)
-spec to_utc(calendar:datetime() | undefined | time_not_exists, string() | binary() | z:context()) -> calendar:datetime() | undefined.
Link to this function
undefined_if_invalid_date(Date)
Link to this function
week_boundaries(Date)
Link to this function
week_boundaries(Date, WeekStart)
Link to this function
week_start()
Link to this function