DT.Format |
str = DT.Format( format-str AS STRING, year AS INTEGER = EL_DT_Default, month AS INTEGER = EL_DT_Default, day AS INTEGER = EL_DT_Default, hour AS INTEGER = EL_DT_Default, min AS INTEGER = EL_DT_Default, sec AS INTEGER = EL_DT_Default ) AS STRING
Formats the specified date and time according to the format specifier.
The format specifier is the same as used by the C/C++ library function strftime.
%a Abbreviated weekday name %A Full weekday name %b Abbreviated month name %B Full month name %c Date and time representation appropriate for locale %d Day of month as decimal number (01 31) %H Hour in 24-hour format (00 23) %I Hour in 12-hour format (01 12) %j Day of year as decimal number (001 366) %m Month as decimal number (01 12) %M Minute as decimal number (00 59) %p Current locales A.M./P.M. indicator for 12-hour clock %S Second as decimal number (00 59) %U Week of year as decimal number, with Sunday as first day of week (00 53) %w Weekday as decimal number (0 6; Sunday is 0) %W Week of year as decimal number, with Monday as first day of week (00 53) %x Date representation for current locale %X Time representation for current locale %y Year without century, as decimal number (00 99) %Y Year with century, as decimal number %z, %Z Time-zone name or abbreviation; no characters if time zone is unknown %% Percent sign
As in the printf function, the # flag may prefix any formatting code. In that case, the meaning of the format code is changed as follows.
The constant EL_DT_Default is defined as in MyBASIC2_ExtLib.BIS
CONST EL_DT_Default = -1
Example:
$LIBRARY "MyBASIC2_ExtLib" $INCLUDE "MyBASIC2_ExtLib"
CLS
DIM strDate AS STRING DIM strTime AS STRING DIM strDT AS STRING DIM iCmp AS INTEGER
strDT = DT.Format( "%c", 2020, 3, 3, 23, 59, 59 )
PRINT "Old Date: ";strDT, PRINT "New Date: ";DT.GetCurrent(),
' Use Random Number Generator to test a comparison SELECT CASE ROUND( RND * 2 ) CASE 0: iCmp = DT.Compare( DT.GetCurrent(), strDT ) CASE 1: iCmp = DT.Compare( strDT, DT.GetCurrent() ) CASE 2: iCmp = DT.Compare( strDT, strDT ) ENDSELECT
SELECT CASE iCmp CASE -1: PRINT DT.GetCurrent();" is before ";strDT, CASE 0: PRINT strDT;" is the same time as ";DT.GetCurrent(), CASE 1: PRINT strDT;" is later than ";DT.GetCurrent(), CASE ELSE PRINT "System is either drunk or messed up !", ENDSELECT
PRINT "[End]",
END |