Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: UDF TmsHms to user local format
The best part is that returns the date with the user language and shortdate system format, timedate returns always in english, at least for me. It uses api calls so it is not fast.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; ;TimeYmdHmsToDate : Converts time from system format to human readable format ; ; using the user language and system shortdate format. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; ;(s) time : a date time in the form YYYY:MM:DD:HH:MM:SS ; ;Returns :a string in the form: ; ; ddd : Day of week as a three-letter abbreviation(user language) ; ; shortdate : shortdate format taken from system win.ini ; ; HH : hour ; ; MM : minutes ; ; SS : seconds ; ;Api:LOCALE_USER_DEFAULT = 1024 ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; #definefunction TimeYmdHmsToDate(time) DLLName = StrCat(DirWindows(1), "kernel32.dll") ;fill SYSTEMTIME structure SYSTEMTIME = binaryalloc(16) binarypoke2(SYSTEMTIME, 0, itemextract(1, time, ":")) ;year binarypoke2(SYSTEMTIME, 2, itemextract(2, time, ":")) ;month binarypoke2(SYSTEMTIME, 4, (TimeJulianDay(time)+5) mod 7) ;day of week binarypoke2(SYSTEMTIME, 6, itemextract(3, time, ":")) ;day binarypoke2(SYSTEMTIME, 8, itemextract(4, time, ":")) ;hour binarypoke2(SYSTEMTIME, 10,itemextract(5, time, ":")) ;minute binarypoke2(SYSTEMTIME, 12,itemextract(6, time, ":")) ;seconds ;leave milliseconds to 00 ;get shortdate format from win.ini shortdate = IniRead("intl", "sShortDate", "") ;buffer to recieve the human date date = binaryalloc(100) ;build human date DLLCall(DLLName, long:"GetDateFormatA", long:1024, long:0, lpbinary:SYSTEMTIME, lpstr:strcat("ddd", " ", itemextract(1, shortdate, "/"), "/", itemextract(2, shortdate, "/"), "/", itemextract(3, shortdate, "/")), lpbinary:Date, long:100) binaryeodset(date, 100) humandate = binarypeekstr(date, 0, 100) binaryfree(SYSTEMTIME) binaryfree(date) return strcat(strupper(StrSub(humandate, 1, 1)), strsub(humandate, 2, -1), " ", itemextract(4, time, ":"), ":", itemextract(5, time, ":"), ":", itemextract(6, time, ":")) #endfunction ;example ;get tomorrow time in human readable format d = TimeYmdHmsToDate(timeadd(TimeYmdHms(), "0000:00:01:00:00:00")) message("Tomorrow at this time:", d)
Article ID: W15322
File Created: 2002:09:05:13:51:20
Last Updated: 2002:09:05:13:51:20