Name
FormatDate -- format date template (V10.0)
Synopsis
d$ = FormatDate(fmt$, date$[, isdst])
Function
This function formats the date passed in date$ according to the format template passed in fmt$ and returns the result. This allows you to convert date and time format templates returned by GetLocaleInfo() to human-readable dates. The date string passed in date$ must be in the default date and time notation used by Hollywood:

 
dd-mmm-yyyy hh:mm:ss

The dd part is a two digit date specification (with leading zeros) and the mmm constituent is a string with three characters identifying the month. This can be Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, or Dec. The yyyy is a four digit year specification whereas hh specifies the hours, mm the minutes and ss the seconds.

The date template passed in date$ can contain string literals as well the following tokens:

%a
Abbreviated weekday name
%A
Weekday name
%b
Abbreviated month name
%B
Month name
%d
Day number with leading zeros
%-d
Day number without leading zeros
%H
Hour using 24-hour style with leading zeros
%-H
Hour using 24-hour style without leading zeros
%I
Hour using 12-hour style with leading zeros
%-I
Hour using 12-hour style without leading zeros
%m
Month number with leading zeros
%-m
Month number without leading zeros
%M
Number of minutes with leading zeros
%-M
Number of minutes without leading zeros
%S
Number of seconds with leading zeros
%-S
Number of seconds without leading zeros
%y
Year using two digits with leading zeros
%-y
Year using two digits without leading zeros
%Y
Year using four digits with leading zeros

Note that depending on the platform Hollywood is running on some more tokens might be supported but only the ones listed above are guaranteed to work on all platforms.

Only the tokens listed above will be replaced in fmt$. All other characters won't be replaced and will remain as string literals in the returned string. If you want to have a percent character as a string literal in the date template string, you need to escape it by using two percent characters (%%).

The optional argument isdst specifies whether or not daylight saving time is active at the specified date. Normally, you don't have to specify this argument because Hollywood will automatically query this information from the timezone database. It is only necessary to pass this information in case the specified time is ambiguous, i.e. when switching from daylight saving time back to standard time, a certain period of time (typically an hour) is repeated in the night. In Germany, for example, clocks are set back from 3am to 2am when switching from daylight saving time to standard time. This means that the hour between 2am and 3am happens twice: Once in daylight saving time, once in standard time. The isdst argument allows you to specify which hour you are referring to.

Inputs
fmt$
date template string
date$
date string in the Hollywood date notation
isdst
optional: whether or not daylight saving time is active at the specified date (defaults to -1 which means that this information should be retrieved from the local timezone database)
Results
d$
formatted date
Example
d$ = FormatDate(GetLocaleInfo().DateTimeFormat, GetDate(#DATELOCAL))
DebugPrint(d$)
The code above prints the date and time formatted according to the rules of the current locale.

Show TOC