std-cdate->date-string | ![]() |
(std-cdate->date-string <cdate>) ;
(std-cdate->time-string <cdate>) ;
*DATE-FORMAT-STRING* ; global string variable
*TIME-FORMAT-STRING* ; global string variable
These functions convert a AutoCAD specific CDATE number into a string according a global format string. They are the basic low-level date formatting functions which are used for functions like STD-TODAY, STD-TODAY-LONG and such.
The format of the two date format strings default to locale conventions which are retrieved at startup by (STD-SYS-LOCALE).
For the US format string default to "m/d/yy" and "hh:nn:ss AMPM"
For Europe it is "dd.mm.yy" and "hh:nn:ss"
Bad Milliseconds Accuracy
Since the CDATE number is not good in representing milliseconds don't use these function to print out benchmark results in the milliseconds range. Therefore exits special functions, see STD-TIME for benchmarking or STD-%PORTABLE-RUNTIME for a good number in milliseconds, returned by STD-TIMER-STOP.
Localized month and weekday names
Translations for month and weekday names are given in STDLOCAL which is loaded if the AutoCAD language is not the symbol :ENGLISH. All these localization issues depend on the AutoCAD language and not on the locale setting! If the AutoCAD prompts are english it is assumed that the user understands english month and weekday names too.
However the defaults for the date format strings depend on the locale setting, because this setting is provided by the operating system (Win32: Control Panel: Country settings).
Note for temp. std-sys-locale workaround
So far we have no implementation of STD-SYS-LOCALE.
Currently it's set per language, for all not english AutoCAD versions to "dd.mm.yy" and "hh:nn:ss"
The format of date strings follow the usual conventions,
But not all format string options -present for example in Visual Basic- are supported yet.
Magic String | Meaning |
yyyy | long year, 4 digits |
yy | short year, 2 digits |
mmmm | long month string |
mmm | 3char month string abbrevation |
mm | month 2 digits |
m | month 1 digit if zero |
dddd | day of week long string (Sunday) |
ddd | 2char day of week string abbrevation (Su-Sa) |
dd | day 2 digits |
d | day 1 digit if zero |
hh | hour 2 digits |
h | hour 1 digit if zero |
nn | minutes 2 digits |
n | minutes 1 digit if zero |
sss | seconds with milliseconds as fractional part |
ss | seconds 2 digits |
s | seconds 1 digit if zero |
ampm | am or pm literal suffix |
AMPM | AM or PM |
(std-cdate->date-string (getvar "CDATE"))
=> "8/24/98" (setq *DATE-FORMAT-STRING* "dddd, dd. mmm yyyy") (std-cdate->date-string (getvar "CDATE"))
=> "Sunday, 24. August 1998" (std-cdate->time-string (getvar "CDATE"))
=> "04:32:12 pm" (setq *TIME-FORMAT-STRING* "[h:n:sss]") (std-cdate->time-string (getvar "CDATE"))
=> "[4:32:13.145]"
cdate: a real number, representing the calendar string
A string according the appropriate format string.
None.
(std-require 'STDTIME)
#- SMALL
Defined in STDTIME
Foreign week and monthnames are defined in STDLOCAL