Page 1 of 1

Simple localised Date/Time functions (I hope)

Posted: Wed Feb 14, 2007 11:47 am
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

Posted: Wed Feb 14, 2007 12:17 pm
by Derek
Works ok in the uk.

Posted: Wed Feb 14, 2007 12:40 pm
by rsts
Fine for gmt-5.

nice.

Posted: Wed Feb 14, 2007 12:44 pm
by utopiomania
Great! Thanks for testing.

Posted: Wed Feb 14, 2007 1:20 pm
by srod
Thanks, this will be useful. :)

Posted: Wed Feb 14, 2007 3:26 pm
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).

Posted: Wed Feb 14, 2007 3:58 pm
by JCV
works here. :)
GMT +8

Posted: Thu Feb 15, 2007 12:06 am
by zikitrake
ok here (GMT+1) :D

Posted: Thu Feb 15, 2007 12:18 am
by SFSxOI
works in the U.S.