HaXtatic Docs

hax.dtFormat

Outputs in a designated output format any input date/time text-values encoded in a designated input format.

In a nutshell

  1. Declaration of an |X|hax.dtFormat:myTag:dtf_in:dtf_out directive in a *.haxproj file,
    • further configuring: (no other settings)
  2. Usage anywhere: {X|myTag: any date/time value currently formatted as inputdtfname or as YYYY-MM-DD |}

This topic is in a compact format for users already familiar with the essentials of declaring X-tags and invoking them. If found challenging, try the more-elaborate-and-introductory topics first to form a better grasp on the basics and overall mechanisms.

Stage:

Early — this X-renderer does not require a page context for rendering: therefore many hax.dtFormat-invoking X-tags encountered during pre-templating (at start-up time) may be eagerly processed immediately in-place (for overall-reduced per-page processing loads).

Declaration / Configuration

Assuming first, the existence of the following (exemplary) named custom date-time formats:

|C|dtformat:mydtf_germanstyle:	%d.%m.%Y
|C|dtformat:mydtf_longmonth:	%d %B
|C|dtformat:mydtf_shortmonth:	%b %d

To demonstrate valid *.haxproj directives declaring hax.dtFormat X-tags:

|X|hax.dtFormat:dt_std2german:
	: mydtf_germanstyle
|X|hax.dtFormat:dt_short2long:
	mydtf_shortmonth : mydtf_longmonth
|X|hax.dtFormat:dt_std2short:
	: mydtf_shortmonth
|X|hax.dtFormat:dt_german2iso:
	mydtf_germanstyle : _hax_dtformat_iso8601
|X|hax.dtFormat:dt_long2std:
	mydtf_longmonth :

Invocation / Parameters

To test the above X-tag declarations:

  • {X|dt_std2german: {P|srcTime|} |}23.10.2017
  • {X|dt_short2long: Mar 14 |}14 March
  • {X|dt_std2short: 1982-02-19 |}Feb 19
  • {X|dt_german2iso: 19.02.1982 |}1982-02-19T00:00:00
  • {X|dt_long2std: December 24 |}1970-12-24