This project has moved and is read-only. For the latest updates, please go here.

DateTime formats for other cultures

Dec 1, 2009 at 8:43 PM


First of all, I would like to congratulate TVA and its initiative to make such a great project open source.
I'm currently working in an application that uses data provided by the openpdc web services as source for charts and all kinds of analyses.
After working a while with it, I discovered that the date format changes according to the language of the server witch the openpdc is running.
So, an en-US server returns months as jan, feb, mar, apr, may...
A pt-BR (I'm in Brazil) one returns months as jan, fev, mar, apr, mai...
The problem shows itself when I have the server (openpdc) and the client (my application) running in different cultures, for instance, the server in en-US and the client in pt-BR or vice-versa.
Since the application has no way to know the language of the openpdc, it crashes trying to convert the month.
Looking into the source code I can see that this action is done in the method ToString() of the TimeTag class:
        /// <summary>
        /// Returns the default text representation of <see cref="TimeTag"/>.
        /// </summary>
        /// <returns><see cref="string"/> that represents <see cref="TimeTag"/>.</returns>
        public override string ToString()
            return ToString("dd-MMM-yyyy HH:mm:ss.fff");
So, how would be the best way to solve that?
- Fix openpdc culture regardless the system culture? If it never changes, it's not a problem :)
CultureInfo cultureInfo = new System.Globalization.CultureInfo("en-US");

System.Threading.Thread.CurrentThread.CurrentCulture =
                System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;

- Use the http Accept-Language header and return what the client is asking for? Rest way :)
- Use the URL for that? /timeseriesdata/write/xml/pt-BR? Ugly!
- Use W3C format for date? (IEC 8601) //it is always good to follow IEC
- Other?
Best Regards,
André Carlucci
Dec 2, 2009 at 7:12 PM

We are thinking we can just change the month to a number in the XML output for the REST service. This should make the date cross-culture friendly...

Dec 2, 2009 at 9:19 PM

Hi André,

The format for time in historian REST web services has been changed to yyyy-MM-dd HH:mm:ss.fff (Example: 2009-12-02 19:39:04.466) and is available in Changeset 38697. The format we chose is very close to W3C date time format you mentioned and should resolve the cross-culture date time issue you ran into.

- Pinal

Dec 3, 2009 at 11:11 AM

Hi Ritchiecarroll, Hi Pinal,

Problem solved.

Thanks a lot for the changes, that was fast :)


André Carlucci