# set_timedate_formats

Definition: | include builtins\timedate.e set_timedate_formats(sequence parse_fmts, object out_fmt=1, integer partial=0)
Description: | Set the format strings to use as defaults on subsequent parsing and display formatting calls.
pwa/p2js: | Supported.
Comments: | The parse_fmts parameter is a list of format strings, each of which is attempted in turn by parse_date_string(). The out_fmt parameter is a single string or index to parse_fmts for format_timedate(). The partial flag controls whether to ignore excess text when parsing, and if set, then parse_fmts should be ordered most detailed first - in the following example you would not want it to completely ignore the trailing "EST", but if no timezone is present then (as shown) you might simply assume it is a local time. The partial flag is currently treated as a boolean but may at some point in the future be extended to take additional settings, for example I can already imagine that one day I might want a value of 2 (or whatever) to mean return {timedate,remaining_text}.
Example 1: |
    include builtins\timedate.e
    set_timedate_formats({"Mmmm d yyyy h:mmam tz"})
Example 2: |
    include builtins\timedate.e
    set_timedate_formats({"h:mmpm tz",
                          "h:mmpm",
                          "h:mm tz",
                          "h:mm"})
    timedate td = parse_date_string("18:05 EST")
    td = set_timezone(td,"GMT")
    ?format_timedate(td)
displays "6:05pm EST" (as the output format defaults to the first element of parse_fmts). If the input to parse_date_string() has a timezone then set_timezone("GMT") has no effect. In this case four formats are required to allow 12 or 24 hour input, with or without an explicit timezone.
See Also: | timedate, timedelta, parse_date_string, set_timezone, format_timedate