Announcement

Collapse
No announcement yet.

Difference between actual time and rawtime

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

  • Difference between actual time and rawtime

    Hi,

    There appears to be a difference between actual time and rawtime. This issue was flagged in 2003 (I believe) where it was stated that the difference was 1 hour and 1 minute. I have just done a calculation and it appears that the difference has grown to almost 2 hours.

    Here are my results:

    Consider the date July 8, 2009 8:00:00 EST.
    Since the EST offset from UT (GMT) is 5:00, this date/time is equivalent to July 8, 2009 13:00:00 UT.
    The Julian date for this is JD 2455021.04167

    Consider the date January 1, 1970 0:00:00 EST.
    Using the offset for UT, this is equivalent to January 1, 1970 05:00:00 UT. The Julian date for this is JD 2440587.70833

    The difference between these two Julian dates is 14433.33334 days or 1,247,040,000.576 seconds

    For the July 8, 2009 08:00 EST bar the rawtick function returns a time of 1,247,054,400 seconds

    The difference between the Julian date difference and the rawtick return value is 14,399.424000024796 seconds which is just under 240 min (239.990 min).

    Can someone please explain to me what I am missing in using the rawtick function. Perhaps the rawtick function does not account for leap seconds, etc. ... Does anyone know how rawtick is computed?

    Any clarification of this matter would be greatly appreciated. Thank you in advance for any help you may be able to provide.

    Regards,
    Jane

  • #2
    Re: Difference between actual time and rawtime

    Jane

    Consider the date July 8, 2009 8:00:00 EST.
    Since the EST offset from UT (GMT) is 5:00, this date/time is equivalent to July 8, 2009 13:00:00 UT.
    On the date you indicate the timezone offset between ET and GMT is actually 4 and not 5 because of DST
    Alex


    Originally posted by jg
    Hi,

    There appears to be a difference between actual time and rawtime. This issue was flagged in 2003 (I believe) where it was stated that the difference was 1 hour and 1 minute. I have just done a calculation and it appears that the difference has grown to almost 2 hours.

    Here are my results:

    Consider the date July 8, 2009 8:00:00 EST.
    Since the EST offset from UT (GMT) is 5:00, this date/time is equivalent to July 8, 2009 13:00:00 UT.
    The Julian date for this is JD 2455021.04167

    Consider the date January 1, 1970 0:00:00 EST.
    Using the offset for UT, this is equivalent to January 1, 1970 05:00:00 UT. The Julian date for this is JD 2440587.70833

    The difference between these two Julian dates is 14433.33334 days or 1,247,040,000.576 seconds

    For the July 8, 2009 08:00 EST bar the rawtick function returns a time of 1,247,054,400 seconds

    The difference between the Julian date difference and the rawtick return value is 14,399.424000024796 seconds which is just under 240 min (239.990 min).

    Can someone please explain to me what I am missing in using the rawtick function. Perhaps the rawtick function does not account for leap seconds, etc. ... Does anyone know how rawtick is computed?

    Any clarification of this matter would be greatly appreciated. Thank you in advance for any help you may be able to provide.

    Regards,
    Jane

    Comment


    • #3
      Re: Re: Difference between actual time and rawtime

      Hi Alex,

      Thank you for pointing out the error. You are absolutely correct. My apologies. I had forgotten about DST in the offset for July.

      Here are my revised results:

      Consider the date July 8, 2009 8:00:00 EST.
      Since the EST offset from UT (GMT) is 4:00:00, this date/time is equivalent to July 8, 2009 12:00:00.0 UT.
      The Julian date for this is JD 2455021.00000

      Consider the date January 1, 1970 0:00:00 EST.
      Using the offset of 5:00:00 for UT, this is equivalent to January 1, 1970 05:00:00 UT. The Julian date for this is JD 2440587.70833

      The difference between these two Julian dates is 14433.29167 days or 1,247,036,400.288 seconds

      For the July 8, 2009 08:00 EST bar the rawtick function returns a time of 1,247,054,400 seconds

      The difference between the Julian date difference and the rawtick return value is 17,999.71199989319 seconds which is just under 300 min (299.995 min).

      Alex, the time has drifted from the past post of 2003 regarding this issue.

      Regards,
      Jane


      Originally posted by Alexis C. Montenegro
      Jane



      On the date you indicate the timezone offset between ET and GMT is actually 4 and not 5 because of DST
      Alex

      Comment


      • #4
        Re: Re: Re: Difference between actual time and rawtime

        Jane

        For the July 8, 2009 08:00 EST bar the rawtick function returns a time of 1,247,054,400 seconds

        The difference between the Julian date difference and the rawtick return value is 17,999.71199989319 seconds which is just under 300 min (299.995 min).
        I would expect that difference given the values used in your calculations. 300 minutes is in fact 5 hours
        rawtime is the time elapsed from 1/1/1970 00:00:00 UTC. The rawtime value you are using however does not take into account the 5 hours of timezone offset which you are instead accounting for in your Julian date calculations
        The rawtime at 05:00:00 UTC is 18,000 and not 0 (see screenshot enclosed below) so
        1,247,054,400 - 18,000 = 1,247,036,400
        This expression now replicates the calculations you are using in the Julian dates
        So the difference between the Julian date calculations and rawtime is of 0.288 seconds and not 300 minutes
        Alex





        Originally posted by jg
        Hi Alex,

        Thank you for pointing out the error. You are absolutely correct. My apologies. I had forgotten about DST in the offset for July.

        Here are my revised results:

        Consider the date July 8, 2009 8:00:00 EST.
        Since the EST offset from UT (GMT) is 4:00:00, this date/time is equivalent to July 8, 2009 12:00:00.0 UT.
        The Julian date for this is JD 2455021.00000

        Consider the date January 1, 1970 0:00:00 EST.
        Using the offset of 5:00:00 for UT, this is equivalent to January 1, 1970 05:00:00 UT. The Julian date for this is JD 2440587.70833

        The difference between these two Julian dates is 14433.29167 days or 1,247,036,400.288 seconds

        For the July 8, 2009 08:00 EST bar the rawtick function returns a time of 1,247,054,400 seconds

        The difference between the Julian date difference and the rawtick return value is 17,999.71199989319 seconds which is just under 300 min (299.995 min).

        Alex, the time has drifted from the past post of 2003 regarding this issue.

        Regards,
        Jane

        Comment


        • #5
          Re: Re: Re: Re: Difference between actual time and rawtime

          Hi Alex,

          Thank you very much for your detailed explanation. I completely understand your explanation and it make sense. It however raises an an aspect of rawtime that I do not understand.

          This result came about from using the following piece of code:

          var firstBarIndex = getOldestBarIndex();
          var myT = null;
          if(null != firstBarIndex) {
          myT = rawtime(firstBarIndex);
          }

          So it appears that this construction sends the bar time (at the bar index referenced) as local time and we then need to apply the timezone offset (accounting for daylight savings time, DST) to this value. Is there a cleaner way to do this? Perhaps by telling rawtime to convert to the correct UT time?

          Thank you very much for all your help. I truly appreciate it.

          Regards,
          Jane


          Originally posted by Alexis C. Montenegro
          Jane



          I would expect that difference given the values used in your calculations. 300 minutes is in fact 5 hours
          rawtime is the time elapsed from 1/1/1970 00:00:00 UTC. The rawtime value you are using however does not take into account the 5 hours of timezone offset which you are instead accounting for in your Julian date calculations
          The rawtime at 05:00:00 UTC is 18,000 and not 0 (see screenshot enclosed below) so
          1,247,054,400 - 18,000 = 1,247,036,400
          This expression now replicates the calculations you are using in the Julian dates
          So the difference between the Julian date calculations and rawtime is of 0.288 seconds and not 300 minutes
          Alex

          Comment


          • #6
            Re: Re: Re: Re: Re: Difference between actual time and rawtime

            Jane
            As I understand it rawtime returns the bar time as UTC and not local time so you need to add the code to convert that to local time and not the other way round
            Try searching the forum as this has been covered before and you should find several examples of how to handle this
            Alex


            Originally posted by jg
            Hi Alex,

            Thank you very much for your detailed explanation. I completely understand your explanation and it make sense. It however raises an an aspect of rawtime that I do not understand.

            This result came about from using the following piece of code:

            var firstBarIndex = getOldestBarIndex();
            var myT = null;
            if(null != firstBarIndex) {
            myT = rawtime(firstBarIndex);
            }

            So it appears that this construction sends the bar time (at the bar index referenced) as local time and we then need to apply the timezone offset (accounting for daylight savings time, DST) to this value. Is there a cleaner way to do this? Perhaps by telling rawtime to convert to the correct UT time?

            Thank you very much for all your help. I truly appreciate it.

            Regards,
            Jane

            Comment


            • #7
              Re: Re: Re: Re: Re: Re: Difference between actual time and rawtime

              Hi Alex,

              Thank you very much for all your help. I shall search the forums for the code suggested.

              Regards,
              Jane


              Originally posted by Alexis C. Montenegro
              Jane
              As I understand it rawtime returns the bar time as UTC and not local time so you need to add the code to convert that to local time and not the other way round
              Try searching the forum as this has been covered before and you should find several examples of how to handle this
              Alex

              Comment


              • #8
                Jane
                FWIW regarding the difference of 0.288 secs the reason may lie in the rounding of the calculation from a date to JD and vice-versa. In fact using the USNO's converter I get the following when converting a date to JD
                The Julian date for CE 1970 January 1 05:00:00.0 UT is
                JD 2440587.70833

                However when converting that same JD back to a date I then get the following
                JD 2440587.70833 is
                CE 1970 January 01 04:59:59.7 UT Thursday

                which returns a difference of 0.3 secs
                Alex

                Comment


                • #9
                  Hi Alex,

                  Thank you very much for the follow up. I very much appreciate it.
                  In the interim I have discovered that the time discrepancy is due to roundoff (or truncation) in the last digit of the USNO's JD.

                  I coded USNO's Julian date converter and for 1970 January 1, 05:00:00.0 UT I get JD 2440587.7083333335. I also coded a converter to Gregorian calendar date and time, and for JD 2440587.7083333335 I get 1970/1/1 5h 0m 0s 0mS (milli seconds).

                  So the discrepancy in the rawtime is most likely due to truncation or roundoff in the Julian date.
                  Regards,
                  Jane

                  Originally posted by Alexis C. Montenegro
                  Jane
                  FWIW regarding the difference of 0.288 secs the reason may lie in the rounding of the calculation from a date to JD and vice-versa. In fact using the USNO's converter I get the following when converting a date to JD
                  The Julian date for CE 1970 January 1 05:00:00.0 UT is
                  JD 2440587.70833

                  However when converting that same JD back to a date I then get the following
                  JD 2440587.70833 is
                  CE 1970 January 01 04:59:59.7 UT Thursday

                  which returns a difference of 0.3 secs
                  Alex

                  Comment

                  Working...
                  X