d$ = FormatDate(fmt$, date$[, isdst])
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
%A
%b
%B
%d
%-d
%H
%-H
%I
%-I
%m
%-m
%M
%-M
%S
%-S
%y
%-y
%Y
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.
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.