Lotus.Web.Dashboards.DateTokens (Lotus Web v1.2.0)

Copy Markdown View Source

The relative date tokens a dashboard filter offers, with their labels.

The tokens and the dates they cover come from Lotus.Dashboards.DateToken. This module gives each token a translated label, puts the tokens in groups for a picker, and formats the dates a token covers on a given day.

Summary

Functions

Formats the dates token covers on today, for example "Aug 17 – Sep 15, 2026". Returns nil when token is not a token.

Formats a date for a person to read, for example "Sep 15, 2026".

Formats a date range for a person to read. A range in one year shows the year once, and a range of one day shows one date.

Returns the tokens a filter of filter_type accepts, in groups for a picker.

Returns the translated label of token.

Returns the concrete value token resolves to on today for a filter of filter_type: "YYYY-MM-DD,YYYY-MM-DD" for a range, "YYYY-MM-DD" for a day.

Returns true when value is a relative date token.

Returns the tokens a filter of filter_type accepts, in picker order.

Functions

describe(token, today)

@spec describe(term(), Date.t()) :: String.t() | nil

Formats the dates token covers on today, for example "Aug 17 – Sep 15, 2026". Returns nil when token is not a token.

format_date(date)

@spec format_date(Date.t()) :: String.t()

Formats a date for a person to read, for example "Sep 15, 2026".

format_range(first, first)

@spec format_range(Date.t(), Date.t()) :: String.t()

Formats a date range for a person to read. A range in one year shows the year once, and a range of one day shows one date.

groups(arg1)

@spec groups(atom()) :: [[String.t()]]

Returns the tokens a filter of filter_type accepts, in groups for a picker.

A :date_range filter accepts every token. A :date filter accepts only the tokens for one day, as Lotus.Storage.DashboardFilter requires. Other filter types accept no token.

label(value)

@spec label(String.t()) :: String.t()

Returns the translated label of token.

resolve(token, filter_type, today)

@spec resolve(String.t(), atom(), Date.t()) :: String.t()

Returns the concrete value token resolves to on today for a filter of filter_type: "YYYY-MM-DD,YYYY-MM-DD" for a range, "YYYY-MM-DD" for a day.

token?(value)

@spec token?(term()) :: boolean()

Returns true when value is a relative date token.

tokens(filter_type)

@spec tokens(atom()) :: [String.t()]

Returns the tokens a filter of filter_type accepts, in picker order.