How to convert date into string regardless of locale
I need to convert timestamp into HTTP-date as defined in section 3.3.1 of [RFC2068]. HTTP-Date can have several representations, but preferable view is defined by RFC 822, updated by RFC 1123 and looks like this:
wkday "," SP date1 SP time SP "GMT"
Here's an example of HTTP-date value:
Sun, 06 Nov 1994 08:49:37 GMT
The problem I encountered, is that if server locale is not English, then $zd, $zdt and TO_CHAR return localized names of weekday and month (i.e: Вос). Is there a way to get English names of weekday and month regardless of server locale?
Just checked TO_CHAR and it also calls $zd.
localeopt parameter solved the problem. This Boolean parameter specifies either the user’s current locale definition or the ODBC locale definition as the source for defaults for the locale-specified parameters dformat, monthlist, yearopt, mindate and maxdate:
For example:
Nice. Thank you!
Hi Eduard,
I came across this post from 2 years ago when trying to work out the simplest way to get current RFC 822/1123 HTTP-Date values from current timestamps for a request header value (eg the %Net.HttpRequest 'Date' property) in something I'm working on.
At the risk of telling you something you've found out elsewhere since then, it turns out there's already a classmethod that will output this (in GMT) from $horolog (or any $horolog-style ddddd,sssss value, with the assumption it's in local time/date):
The Documatic details are here.
Cheers
Joe