Play PackRat on Facebook: our feverishly addictive new game

ASP Date Handling

Okay, this is for some of the more advanced systems programmer's out there:

I like making software & applications as intuitive as possible, saving the users from having to wade through settings, etc. To that end, it has been brought to my attention that the dates in the IB Dashboard aren't displaying correctly for users outside of the US.

So my options are to either offer an option in the database for each user, or dynamically pull a user's locale from their IP address, and display the date accordingly. A third option might be to have ASP handle it without the IP involvement, but I think the server will show dates based on the computer it's running on, so I think that option is out.

Has anyone else run into this kind of issue, or have any suggestions for that I might not have tried? Thank you.

Posted by bjendrick on Oct 15, 2007 in Blab | 2 comments

nickpixel on Oct 15, 2007

Well, depending on what you need to do, there are multiple options. By ASP, I assume you mean Active Server Pages. If so, you can use the server variable "HTTP_ACCEPT_LANGUAGE" which all modern browsers send to determine the locale. If you were using ASP, you could then set the Session objects LCID property based on the LocaleID derived from the HTTP_ACCEPT_LANGUAGE variable to keep the locale setting for the entire session (Session.LCID = 3081 would be for Australian English). Then, assuming you're using VBScript, you'd have to make sure to output currency using "FormatCurrency()" and numbers using "FormatNumber()" but date/time formats would automatically be formatted. Of course, you'd need to provide a method to translate the HTTP_ACCEPT_LANGUAGE to an LCID but those don't change so it's not a big deal. This can also be done in PHP, .NET and Java and, even though I haven't used it for anything, I'd be very surprised if Ruby didn't also have this capability.

Here's a chart mapping language codes to their LCID's.

If you need another option or a basic code sample, let me know.

bjendrick on Oct 15, 2007

Thank you, nickpixel. I had skimmed some of that information, but wasn't aware that it was necessary in my setup. I'll dig into this more, and it looks like it won't be necessary to do anything based on IPs.

Oh, and you guessed correctly for Active Server Pages. Thanx again, and I'll be sure to share my results.