1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-04-08 11:46:40 +00:00

Add documentation for the parsedate filter

This commit is contained in:
Daniel Goß 2022-01-10 21:33:33 +01:00
parent 6ce4e2580c
commit e6d702109b
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,39 @@
created: 20220110203115000
modified: 20220110203115000
tags: [[Operator Examples]] [[parsedate Operator]]
title: parsedate Operator (Examples)
isodate: 2022-01-01T12:15:00
type: text/vnd.tiddlywiki
\define utc-datetime() [UTC]MMM the DD. YYYY 0hh:0mm UTC
<<.operator-example 1 "[[2011-01-01T12:15:21]parsedate[JS]]">>
This example uses the `isodate` field of this tiddler containing "<$view field="isodate"/>":
<<.operator-example 2 "[get[isodate]parsedate[JS]]">>
The following example uses a HTML5 date and time picker in combination with the `parsedate` operator to convert the output of the HTML5 input element into TiddlyWiki's [[DateFormat|date format]]. It uses the [[format Operator]] to output the date in human-readable form.
<$macrocall $name=".example" n="3"
eg="""<$edit-text field="isodate" type="datetime-local"/><br/><$text text={{{[get[isodate]parsedate[JS]format:date[MMM the DDth YYYY at 0hh:0mm]]}}}/>"""/>
! Time zone examples for format `JS`
The following examples use the predefined variable `utc-datetime` that outputs the date and time in UTC for illustration.
Values that contain date and time but no time zone information are interpreted within the local timezone. This date is midnight on January the 1st, 2011 in the local timezone. Observe how it is converted to UTC.
<<.operator-example 4 "[[2011-01-01T00:00:00]parsedate[JS]format:date<utc-datetime>]">>
Values that contain only a date are interpreted as UTC. This makes sure that the date is not changed by the conversion. If your time zone is ahead of UTC in the above example, the date will change to December the 31st, 2010. In this example, the date will be correctly represented.
<<.operator-example 5 "[[2011-01-01]parsedate[JS]format:date<utc-datetime>]">>
Appending a `Z` to the Date and Time information makes sure it is always interpreted as UTC. The local time zone is ignored.
<<.operator-example 6 "[[2011-01-01T00:00:00Z]parsedate[JS]format:date<utc-datetime>]">>
Instead of `Z` a time zone offset can be specified. This offset will be used to interprete the date and time information. The local time zone is ignored.
<<.operator-example 7 "[[2011-01-01T00:00:00+05:00]parsedate[JS]format:date<utc-datetime>]">>

View File

@ -0,0 +1,22 @@
caption: parsedate
created: 20220110203115000
modified: 20220110203115000
op-input: a [[selection of titles|Title Selection]]
op-output: the date stored within the input string converted to the default [[date format|DateFormat]] <<.place B>>
op-parameter: source format
op-parameter-name: B
op-purpose: parse the input string and convert it into the default [[date format|DateFormat]]
tags: [[Filter Operators]] [[Date Operators]]
title: parsedate Operator
type: text/vnd.tiddlywiki
<<.from-version "5.2.2">>
The parameter <<.place B>> is one of the following supported input formats:
|!Format |!Description |
|^`JS` |The input string is interpreted as a date in [[ECMAScript date format|https://tc39.es/ecma262/#sec-date-time-string-format]]. This format is a subset of ISO 8601. It is used for example by the HTML5 date/time input fields. Expanded years are ''not supported''.|
If the input string does not contain a valid date, the output is an empty list.
<<.operator-examples "parsedate">>