Module z_datetime

Utility functions for datetime handling and representation.

Copyright 2009-2014 Marc Worrell

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

Description

Utility functions for datetime handling and representation.

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/3Format a date/time.
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_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_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_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

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/3

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

Format a date/time. Convenience function which calls the zotonic erlydtl stub.

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.

next_second/1

next_second(Date) -> any()

Return the date one second 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_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_local/2

to_local(Date::calendar:datetime(), Tz::string() | binary() | #context{}) -> calendar:datetime()

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

to_utc/2

to_utc(Date::calendar:datetime(), Tz::string() | binary() | #context{}) -> calendar:datetime()

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()


Generated by EDoc, Oct 1 2014, 01:46:52.