Last change: June 20, 2020
Current version: 1.3.0
The date module can transform written dates to timestamps and visa versa. It also has some extra manipulation tasks.
syntax
webanizr.send('date', data, parameters, callack);
webanizr.collect('date', parameters, callack);
Send
data
The data contains a list of dates to transform. It can also contain the dates used for actions.
parameters
The data module accepts the following parameters:
type__action (optional)
The action that needs to be performed on the dates in data. If no action is given, the action 'convert' is assumed. The following actions are supported:
- convert: convert the given dates to another format
- fill-range: fill a list of DOM elements with increasing dates
- incrementdays: adds nr__days amount of days to given date.
- translate: translate the list of date related words
abbr__language (optional)
The language to be used for the formatted dates. If no language is given, engllish is assumed. The following languages are supported:
type__conversion (optional)
The type op formatting to be used for creating the written date(s). The following options are supported:
- month: the full name of the month in the given language
- timestamp: the date as miliseconds since 1 january 1970
- utc: the date as full utc string
- auto: the default representation of the date of the browser
- format: use a format string to format the date
format__date (required when type__conversion == format)
A string that defines how the date should be formatted. The string can contain the following substring that will be replaced:
- %a - An abbreviated textual representation of the day - Sun through Sat
- %A - A full textual representation of the day - Sunday through Saturday
- %d - Two-digit day of the month (with leading zeros) - 01 to 31
- %e - Day of the month, with a space preceding single digits. - 1 to 31
- %u - ISO-8601 numeric representation of the day of the week - 1 (for Monday) through 7 (for Sunday)
- %w - Numeric representation of the day of the week - 0 (for Sunday) through 6 (for Saturday)
- %b - Abbreviated month name - Jan through Dec
- %B - Full month name - January through December
- %h - Abbreviated month name (an alias of %b) - Jan through Dec
- %m - Two digit representation of the month - 01 (for January) through 12 (for December)
- %Y - Four digit representation for the year - Example: 2038
query__selector (required when action == fill-range)
The selector to the dom elements that need to be filled with the dates
nr__skip (optional for action == fill-range)
The number of elements to skip before starting to fill the elements with the dates.
nr__days (optional for action == incrementdays)
The amount of days to add to the date(s) given in data. nr__days can be a negative number so that it subtracts given amount of days.
callback
The callback is called with the reformatted dates.
Collect
parameters
The data module accepts the following parameters:
type__action (required)
The action that needs to be performed. The following actions are supported:
- months: send the name of the months to the callback
abbr__language (optional)
The language to be used for the formatted dates. If no language is given, engllish is assumed. The following languages are supported:
callback
The callback is called with the data that followed from the chosen action.
demo
https://cdn.cpmodules.webanizr.com/demo/calendar/index.html
Changelog
- March 06, 2020: 1.3.0 - Added the translate option
- March 06, 2020: 1.2.2 - Fixed the bug that it doesn't increment days then type__conversion is set
- March 06, 2020: 1.2.1 - Added type__conversion option to the incrementdays
- March 06, 2020: 1.2.0 - Added incrementdays action and nr__days parameter
- September 13, 2019: 1.1.1 - Dates with slashes, eg 23/10/2019, are now accepted
- September 11, 2019: 1.1.0 - Added the collect and the action "months"
- August 22, 2019: 1.0.1 - Fixed lookup for correct day of month
- August 20, 2019: 1.0.0 - initial stable version