System date format

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

System date format

Post by USCode »

There is a system date format, based on the user's OS preferences, for displaying dates. E.g. in Europe the date is typically displayed DD/MM/YYYY, whereas in the U.S. it's MM/DD/YYYY ... it would be nice if there was a way to retrieve this format and/or have the data automatically formatted based on the user's regional preferences ... for both dates and times.

Perhaps as a set of Masks in the FormatDate() command?
e.g.
%SystemDateFormat
%SystemTimeFormat

would display the date or time in the format appropriate to the user's settings. I'm sure Fred could come up with a better solution!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: System date format

Post by PB »

I just found this post and here's a quick-and-dirty hack, just to point you in
the right direction. It's your responsibility to clean it up and make it work in
all situations. :)

Code: Select all

shortdate$=Space(10) : GetLocaleInfo_(#LOCALE_USER_DEFAULT,#LOCALE_SSHORTDATE,shortdate$,10)
Debug shortdate$

a$=ReplaceString(shortdate$,"/","/%")
a$=ReplaceString(a$,"d","%dd")
Debug FormatDate(a$,Date())
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Post Reply