Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

European date format and strings

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    European date format and strings

    I have an indicator which compares some strings that hold dates in US format of "MM/DD/YYYY hh:mm:ss" and it has come to my attention from a European user that the indicator fails because of the difference in the Date format (DD/MM/YYYY). To get around it I have used this:

    if(CultureInfo.CurrentCulture.Name == "en-US")
    {
    Do something with the US formatted strings
    }
    else
    {
    Do something with alternate Euro strings
    }

    Since working with time and dates makes my head spin, my question is should I be doing this in a better way?

    Dan
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    #2
    Dan, one idea would be working for example into UTC only and then converting back to user time as needed -

    Converts the value of the current DateTime object to Coordinated Universal Time (UTC).


    If you don't want to work with DateTime objects, you could work with ToTime() & ToDay() to convert those to integers.



    Comment


      #3
      Dan,

      if it is you who creates the strings, you could use the invariant format for the time/date-string-formatting:

      DateTimeFormatInfo.InvariantInfo;

      It doesn't change the used time zones but it provides an unique format very similar to the american style.

      Regards
      Ralph

      P.S: There is no european style for Date/Time. For example even the string format of british an german Date/Time values would differ.
      Last edited by Ralph; 03-24-2010, 06:14 AM.

      Comment


        #4
        Originally posted by NinjaTrader_Bertrand View Post
        Dan, one idea would be working for example into UTC only and then converting back to user time as needed -

        Converts the value of the current DateTime object to Coordinated Universal Time (UTC).


        If you don't want to work with DateTime objects, you could work with ToTime() & ToDay() to convert those to integers.



        http://www.ninjatrader-support.com/H...eV6/ToDay.html
        Thanks Bertrand but it is the Date format that causes the problem, not Time so I believe using any conversions to UTC would have no effect. Ralph, are you saying there is a format for Date strings that can be read universally? I may need to get more info from you about that. Dan
        eDanny
        NinjaTrader Ecosystem Vendor - Integrity Traders

        Comment


          #5
          Dan, you're right would apply only to the time component as a quick test showed - perhaps the the From / To binary method is of value for your endavour?

          Comment


            #6
            Dan, here is a quick test. I executed the following code with german time:

            Print(Time[0].ToString());
            Print(Time[
            0].ToString(DateTimeFormatInfo.InvariantInfo));

            And here is the result. The first line is the native string and the second line the invariant version. If you execute this code on your side, your invariant result should have the same syntax:

            25.03.2010 18:39:02
            03/25/2010 18:39:02

            Don't forget to insert:
            using System.Globalization;

            Regards,
            Ralph

            Comment


              #7
              On a wider note, I'd like to remind you about this thread (which is closed, but not resolved)



              I realise it's not on your radar much, but it's really irritating to those of us outside the US..

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              649 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              370 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              109 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              573 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              576 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X