Simple localised Date/Time functions (I hope)

Share your advanced PureBasic knowledge/code with the community.
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Simple localised Date/Time functions (I hope)

Post by utopiomania »

Code updated for 5.20+

This is two date/time functions that returns the date/time in the users default format
without the need for a mask$ (at least I hope they work that way).

I'm using them in a text editor Edit/Date Edit/Time menu to insert the result at the
caret position. Please tell me if they return wrong results in other parts of the world.


Code: Select all

procedure.s dateStr() 
  str.s = Space(12) 
  GetDateFormat_(#LOCALE_USER_DEFAULT, 0, 0, 0, str, 12) 
  ProcedureReturn str
EndProcedure

procedure.s timeStr() 
  str.s = Space(12) 
  GetTimeFormat_(#LOCALE_USER_DEFAULT, 0, 0, 0, str, 12) 
  ProcedureReturn str
EndProcedure

messageRequester("Localised Date/Time:", dateStr() + #CRLF$ + timeStr())
end
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Works ok in the uk.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Fine for gmt-5.

nice.
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

Great! Thanks for testing.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Thanks, this will be useful. :)
I may look like a mule, but I'm not a complete ass.
FreeThought
User
User
Posts: 54
Joined: Mon Jul 18, 2005 10:28 am

Post by FreeThought »

Thanks , That is very nice , I have small suggestion if I may, if you replace the null in the second param with #LOCALE_NOUSEROVERRIDE , will display
the am pm designator in the local language correctly in time format.(for non Latin language).
Last edited by FreeThought on Thu Feb 15, 2007 3:11 am, edited 1 time in total.
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Post by JCV »

works here. :)
GMT +8
zikitrake
Addict
Addict
Posts: 876
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Post by zikitrake »

ok here (GMT+1) :D
PB 6.21 beta, PureVision User
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

works in the U.S.
Post Reply