Date Comparison and Manipulation Functions?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • W. eWatson

    Date Comparison and Manipulation Functions?

    Are there some date and time comparison functions that would compare, say,

    Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd)
    Is 02/11/07 the same as 02/11/07?

    Is 14:05:18 after 22:02:51? (24 hour day is fine)

    How about the date after 02/28/04 is 02/29/04, or the date after 09/30/08 is
    10/01/08?

    How about is 03/03/04 20:10:08 after 03/07/03 14:00:00? Probably the others
    above will suffice.
    --
    Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

    (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
    Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

    Web Page: <www.speckledwi thstars.net/>
  • Paul Rudin

    #2
    Re: Date Comparison and Manipulation Functions?

    "W. eWatson" <notvalid2@sbcg lobal.netwrites :
    Are there some date and time comparison functions that would compare, say,
    >
    Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd)
    Is 02/11/07 the same as 02/11/07?
    >
    Is 14:05:18 after 22:02:51? (24 hour day is fine)
    >
    How about the date after 02/28/04 is 02/29/04, or the date after
    09/30/08 is 10/01/08?
    >
    How about is 03/03/04 20:10:08 after 03/07/03 14:00:00? Probably the
    others above will suffice.
    Source code: Lib/datetime.py The datetime module supplies classes for manipulating dates and times. While date and time arithmetic is supported, the focus of the implementation is on efficient attr...

    Comment

    • zuul@ferg.org

      #3
      Re: Date Comparison and Manipulation Functions?

      check out Pyfdate: http://www.ferg.org/pyfdate

      from pyfdate import *

      t = Time().add(hour s=14)
      print "It is now", t.wdt

      datestring1 = "2005/10/05" #year,month,day
      datestring2 = "2002/09/22" #year,month,day
      datestring3 = "2007/11/11" #year,month,day

      year,month,day = numsplit(datest ring1) # split into integers
      t1 = Time(year,month ,day)
      for datestring in (datestring2,da testring1,dates tring3):
      year,month,day = numsplit(datest ring)
      t2 = Time(year,month ,day)

      if t1 t2:
      print t1.isodate, "is later than ", t2.isodate
      elif t1 == t2:
      print t1.isodate, "is the same as ", t2.isodate
      elif t1 < t2:
      print t1.isodate, "is earlier than", t2.isodate

      print

      t1 = Time(2000,2,28)
      print "The date after", t1.d, "is", t1.plus(day=1). d
      t1 = Time(2001,2,28)
      print "The date after", t1.d, "is", t1.plus(day=1). d
      t1 = Time(2004,2,28)
      print "The date after", t1.d, "is", t1.plus(day=1). d

      print
      datestring1 = "2005/10/05 20:10:08"
      datestring2 = "2005/10/05 20:10:06"
      datestring3 = "2005/10/05 20:10:09"

      t1 = Time(*numsplit( datestring1))
      for datestring in (datestring2,da testring1,dates tring3):
      t2 = Time(*numsplit( datestring))

      if t1 t2:
      print t1.d, t1.civiltime2, "is later than ", t2.d, t2.civiltime2
      elif t1 == t2:
      print t1.d, t1.civiltime2, "is the same as ", t2.d, t2.civiltime2
      elif t1 < t2:
      print t1.d, t1.civiltime2, "is earlier than", t2.d, t2.civiltime2

      Comment

      • W. eWatson

        #4
        Re: Date Comparison and Manipulation Functions?

        zuul@ferg.org wrote:
        check out Pyfdate: http://www.ferg.org/pyfdate
        >
        from pyfdate import *
        >
        t = Time().add(hour s=14)
        print "It is now", t.wdt
        >
        datestring1 = "2005/10/05" #year,month,day
        datestring2 = "2002/09/22" #year,month,day
        datestring3 = "2007/11/11" #year,month,day
        >
        year,month,day = numsplit(datest ring1) # split into integers
        t1 = Time(year,month ,day)
        for datestring in (datestring2,da testring1,dates tring3):
        year,month,day = numsplit(datest ring)
        t2 = Time(year,month ,day)
        >
        if t1 t2:
        print t1.isodate, "is later than ", t2.isodate
        elif t1 == t2:
        print t1.isodate, "is the same as ", t2.isodate
        elif t1 < t2:
        print t1.isodate, "is earlier than", t2.isodate
        >
        print
        >
        t1 = Time(2000,2,28)
        print "The date after", t1.d, "is", t1.plus(day=1). d
        t1 = Time(2001,2,28)
        print "The date after", t1.d, "is", t1.plus(day=1). d
        t1 = Time(2004,2,28)
        print "The date after", t1.d, "is", t1.plus(day=1). d
        >
        print
        datestring1 = "2005/10/05 20:10:08"
        datestring2 = "2005/10/05 20:10:06"
        datestring3 = "2005/10/05 20:10:09"
        >
        t1 = Time(*numsplit( datestring1))
        for datestring in (datestring2,da testring1,dates tring3):
        t2 = Time(*numsplit( datestring))
        >
        if t1 t2:
        print t1.d, t1.civiltime2, "is later than ", t2.d, t2.civiltime2
        elif t1 == t2:
        print t1.d, t1.civiltime2, "is the same as ", t2.d, t2.civiltime2
        elif t1 < t2:
        print t1.d, t1.civiltime2, "is earlier than", t2.d, t2.civiltime2
        It looks good. Thanks.

        --
        Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

        (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
        Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

        Web Page: <www.speckledwi thstars.net/>

        Comment

        • W. eWatson

          #5
          Re: Date Comparison and Manipulation Functions?

          zuul@ferg.org wrote:
          check out Pyfdate: http://www.ferg.org/pyfdate
          >
          from pyfdate import *
          >
          t = Time().add(hour s=14)
          print "It is now", t.wdt
          >
          datestring1 = "2005/10/05" #year,month,day
          datestring2 = "2002/09/22" #year,month,day
          datestring3 = "2007/11/11" #year,month,day
          >
          year,month,day = numsplit(datest ring1) # split into integers
          t1 = Time(year,month ,day)
          for datestring in (datestring2,da testring1,dates tring3):
          year,month,day = numsplit(datest ring)
          t2 = Time(year,month ,day)
          >
          if t1 t2:
          print t1.isodate, "is later than ", t2.isodate
          elif t1 == t2:
          print t1.isodate, "is the same as ", t2.isodate
          elif t1 < t2:
          print t1.isodate, "is earlier than", t2.isodate
          >
          print
          >
          t1 = Time(2000,2,28)
          print "The date after", t1.d, "is", t1.plus(day=1). d
          t1 = Time(2001,2,28)
          print "The date after", t1.d, "is", t1.plus(day=1). d
          t1 = Time(2004,2,28)
          print "The date after", t1.d, "is", t1.plus(day=1). d
          >
          print
          datestring1 = "2005/10/05 20:10:08"
          datestring2 = "2005/10/05 20:10:06"
          datestring3 = "2005/10/05 20:10:09"
          >
          t1 = Time(*numsplit( datestring1))
          for datestring in (datestring2,da testring1,dates tring3):
          t2 = Time(*numsplit( datestring))
          >
          if t1 t2:
          print t1.d, t1.civiltime2, "is later than ", t2.d, t2.civiltime2
          elif t1 == t2:
          print t1.d, t1.civiltime2, "is the same as ", t2.d, t2.civiltime2
          elif t1 < t2:
          print t1.d, t1.civiltime2, "is earlier than", t2.d, t2.civiltime2
          I'm using IDLE for Python 2.4, and put pfydate distribution in
          C:\Python24\Lib \site-packages\pfydat e, as required by the
          <ttp://www.ferg.org/pyfdate/download.htmlpa ge.
          How to install pyfdate.

          Save pyfdate.py into your PythonNN/Lib/site-packages directory.
          I copied it into C:\Python24\Lib \site-packages\pfydat e

          Execution in IDLE produced:
          ---------------------------------
          Traceback (most recent call last):
          File
          "C:\Sandia_Mete ors\Improved_Se ntinel\Sentinel _Playground\dat e_example.py",
          line 1, in ?
          from pyfdate import *
          ImportError: No module named pyfdate
          ---------------------------------
          Looking in the Path Browser, I don't see pyfdate. I see PIL package and
          scipy package.

          Comments?

          --
          Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

          (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
          Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

          Web Page: <www.speckledwi thstars.net/>

          Comment

          • John Machin

            #6
            Re: Date Comparison and Manipulation Functions?

            On Aug 27, 10:21 am, "W. eWatson" <notval...@sbcg lobal.netwrote:
            >
            I'm using IDLE for Python 2.4, and put pfydate distribution in
            C:\Python24\Lib \site-packages\pfydat e, as required by the
            <ttp://www.ferg.org/pyfdate/download.htmlpa ge.
            How to install pyfdate.
            >
            Save pyfdate.py into your PythonNN/Lib/site-packages directory.
            I copied it into C:\Python24\Lib \site-packages\pfydat e
            If that means that you ended up with
            C:\Python24\Lib \site-packages\pfydat e\pyfdate.py
            then you have *not* followed the instructions "Save pyfdate.py into
            your PythonNN/Lib/site-packages directory".
            You need to end up with
            C:\Python24\Lib \site-packages\pyfdat e.py

            If in doubt, get to a command prompt and type
            dir C:\Python24\Lib \site-packages\pfydat e*
            and tell us what you see.
            >
            Execution in IDLE produced:
            ---------------------------------
            Traceback (most recent call last):
            File
            "C:\Sandia_Mete ors\Improved_Se ntinel\Sentinel _Playground\dat e_example.py",
            line 1, in ?
            from pyfdate import *
            ImportError: No module named pyfdate
            ---------------------------------
            Looking in the Path Browser, I don't see pyfdate. I see PIL package and
            scipy package.

            Comment

            • W. eWatson

              #7
              Re: Date Comparison and Manipulation Functions?

              John Machin wrote:
              On Aug 27, 10:21 am, "W. eWatson" <notval...@sbcg lobal.netwrote:
              >I'm using IDLE for Python 2.4, and put pfydate distribution in
              >C:\Python24\Li b\site-packages\pfydat e, as required by the
              ><ttp://www.ferg.org/pyfdate/download.htmlpa ge.
              >How to install pyfdate.
              >>
              > Save pyfdate.py into your PythonNN/Lib/site-packages directory.
              >I copied it into C:\Python24\Lib \site-packages\pfydat e
              >
              If that means that you ended up with
              C:\Python24\Lib \site-packages\pfydat e\pyfdate.py
              then you have *not* followed the instructions "Save pyfdate.py into
              your PythonNN/Lib/site-packages directory".
              You need to end up with
              C:\Python24\Lib \site-packages\pyfdat e.py
              None of the folders in C:\Python24\Lib \site-packages\ have py as a suffix
              (as seen either by the IDLE path browser or XP). My folder is exactly
              C:\Python24\Lib \site-packages\pfydat e in XP and it contains about 12 py files.
              There are exactly three folders under
              C:\Python24\Lib \site-packages\ according to the IDLE path browser. This does
              not agree with XP, which has:
              Numeric
              pfydate
              scipy
              numpy
              PIL
              >
              If in doubt, get to a command prompt and type
              dir C:\Python24\Lib \site-packages\pfydat e*
              and tell us what you see.
              >
              >Execution in IDLE produced:
              >---------------------------------
              >Traceback (most recent call last):
              > File
              >"C:\Sandia_Met eors\Improved_S entinel\Sentine l_Playground\da te_example.py",
              >line 1, in ?
              > from pyfdate import *
              >ImportError: No module named pyfdate
              >---------------------------------
              >Looking in the Path Browser, I don't see pyfdate. I see PIL package and
              >scipy package.

              --
              Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

              (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
              Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

              Web Page: <www.speckledwi thstars.net/>

              Comment

              • John Machin

                #8
                Re: Date Comparison and Manipulation Functions?

                On Aug 27, 11:24 am, "W. eWatson" <notval...@sbcg lobal.netwrote:
                John Machin wrote:
                On Aug 27, 10:21 am, "W. eWatson" <notval...@sbcg lobal.netwrote:
                I'm using IDLE for Python 2.4, and put pfydate distribution in
                C:\Python24\Lib \site-packages\pfydat e, as required by the
                <ttp://www.ferg.org/pyfdate/download.htmlpa ge.
                How to install pyfdate.
                >
                     Save pyfdate.py into your PythonNN/Lib/site-packages directory.
                I copied it into C:\Python24\Lib \site-packages\pfydat e
                >
                If that means that you ended up with
                   C:\Python24\Lib \site-packages\pfydat e\pyfdate.py
                then you have *not* followed the instructions "Save pyfdate.py into
                your PythonNN/Lib/site-packages directory".
                You need to end up with
                   C:\Python24\Lib \site-packages\pyfdat e.py
                >
                None of the folders in C:\Python24\Lib \site-packages\ have py as a suffix
                (as seen either by the IDLE path browser or XP). My folder is exactly
                C:\Python24\Lib \site-packages\pfydat e in XP and it contains about 12 py files.
                There are exactly three folders under
                C:\Python24\Lib \site-packages\ according to the IDLE path browser. This does
                not agree with XP, which has:
                Numeric
                pfydate
                scipy
                numpy
                PIL
                (1) "pfydate" != "pyfdate"
                (2) The instructions say to put pyfdate.py [that's *ONE* file, not 12
                files] in the ..../site-packages folder, *not* a sub-folder

                Comment

                • W. eWatson

                  #9
                  Re: Date Comparison and Manipulation Functions?

                  John Machin wrote:
                  On Aug 27, 11:24 am, "W. eWatson" <notval...@sbcg lobal.netwrote:
                  >John Machin wrote:
                  >>On Aug 27, 10:21 am, "W. eWatson" <notval...@sbcg lobal.netwrote:
                  >>>I'm using IDLE for Python 2.4, and put pfydate distribution in
                  >>>C:\Python24\ Lib\site-packages\pfydat e, as required by the
                  >>><ttp://www.ferg.org/pyfdate/download.htmlpa ge.
                  >>>How to install pyfdate.
                  >>> Save pyfdate.py into your PythonNN/Lib/site-packages directory.
                  >>>I copied it into C:\Python24\Lib \site-packages\pfydat e
                  >>If that means that you ended up with
                  >> C:\Python24\Lib \site-packages\pfydat e\pyfdate.py
                  >>then you have *not* followed the instructions "Save pyfdate.py into
                  >>your PythonNN/Lib/site-packages directory".
                  >>You need to end up with
                  >> C:\Python24\Lib \site-packages\pyfdat e.py
                  >None of the folders in C:\Python24\Lib \site-packages\ have py as a suffix
                  >(as seen either by the IDLE path browser or XP). My folder is exactly
                  >C:\Python24\Li b\site-packages\pfydat e in XP and it contains about 12 py files.
                  >There are exactly three folders under
                  >C:\Python24\Li b\site-packages\ according to the IDLE path browser. This does
                  >not agree with XP, which has:
                  >Numeric
                  >pfydate
                  >scipy
                  >numpy
                  >PIL
                  >
                  (1) "pfydate" != "pyfdate"
                  typo
                  (2) The instructions say to put pyfdate.py [that's *ONE* file, not 12
                  files] in the ..../site-packages folder, *not* a sub-folder
                  >
                  Got it. Ah, I see upon closer inspection the other files are just
                  international versions. Thanks. It works.

                  --
                  Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

                  (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
                  Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

                  Web Page: <www.speckledwi thstars.net/>

                  Comment

                  • W. eWatson

                    #10
                    Re: Date Comparison and Manipulation Functions?

                    I just tried the following code, and got an unexpected result.

                    from pyfdate import *
                    t = Time()

                    ts = Time(2008, 8, 29,15,20,7)
                    tnew = ts.plus(months= 6)
                    print "new date: ", tnew

                    Result:
                    new date: 2009-02-28 15:20:07

                    I believe that should be April 1, 2009. If I use months = 1 and day =31, I
                    get Sept. 30, 2008 and not Oct. 1, 2008. Is there a way to get around this?

                    --
                    W. Watson
                    (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
                    Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

                    Comment

                    • John Machin

                      #11
                      Re: Date Comparison and Manipulation Functions?

                      On Aug 30, 2:32 am, "W. eWatson" <notval...@sbcg lobal.netwrote:
                      I just tried the following code, and got an unexpected result.
                      >
                      from pyfdate import *
                      t = Time()
                      >
                      ts = Time(2008, 8, 29,15,20,7)
                      tnew = ts.plus(months= 6)
                      print "new date: ", tnew
                      >
                      Result:
                      new date: 2009-02-28 15:20:07
                      >
                      I believe that should be April 1, 2009.
                      Presuming that we are talking about the Gregorian calendar, and not
                      one of your own invention, you are (one trusts) alone in that belief.
                      There are SEVEN whole months and a bit between August 29, 2008 and
                      April 1, 2009. Count the months: Sep, Oct, Nov, Dec, Jan, Feb, Mar.
                      If I use months = 1 and day =31, I
                      get Sept. 30, 2008 and not Oct. 1, 2008. Is there a way to get around this?
                      Because the number of days in a month is not constant, adding a number
                      of months to a date is capable of more than one interpretation. Most
                      folk are happy with adding the months on and then ensuring that the
                      day is not later than the last day of the resultant (year, month)
                      combination -- this is what the pyfdate routine appears to be doing.
                      However there are some interesting ideas floating around e.g. IIRC an
                      eminent personage once asserted in this newsgroup that adding 1 month
                      to 31 Jan in a non-leap year should produce 3 Mar.

                      There is also the general question with date intervals of whether the
                      first day is included in the calculation or not. E.g. work on Monday,
                      Tuesday, Wednesday: that's 3 days service. Put money into the bank on
                      Monday, withdraw it on Wednesday: that's likely to attract 2 days
                      interest.

                      One needs to understand exactly what calculation is required, and
                      exactly what calculation is provided by the software that is proposed
                      to be used.

                      HTH,

                      John

                      Comment

                      • W. eWatson

                        #12
                        Re: Date Comparison and Manipulation Functions?

                        John Machin wrote:
                        On Aug 30, 2:32 am, "W. eWatson" <notval...@sbcg lobal.netwrote:
                        >I just tried the following code, and got an unexpected result.
                        >>
                        >from pyfdate import *
                        >t = Time()
                        >>
                        >ts = Time(2008, 8, 29,15,20,7)
                        >tnew = ts.plus(months= 6)
                        >print "new date: ", tnew
                        >>
                        >Result:
                        >new date: 2009-02-28 15:20:07
                        >>
                        >I believe that should be April 1, 2009.
                        >
                        Presuming that we are talking about the Gregorian calendar, and not
                        one of your own invention, you are (one trusts) alone in that belief.
                        There are SEVEN whole months and a bit between August 29, 2008 and
                        April 1, 2009. Count the months: Sep, Oct, Nov, Dec, Jan, Feb, Mar.
                        >
                        >If I use months = 1 and day =31, I
                        >get Sept. 30, 2008 and not Oct. 1, 2008. Is there a way to get around this?
                        >
                        Because the number of days in a month is not constant, adding a number
                        of months to a date is capable of more than one interpretation. Most
                        folk are happy with adding the months on and then ensuring that the
                        day is not later than the last day of the resultant (year, month)
                        combination -- this is what the pyfdate routine appears to be doing.
                        However there are some interesting ideas floating around e.g. IIRC an
                        eminent personage once asserted in this newsgroup that adding 1 month
                        to 31 Jan in a non-leap year should produce 3 Mar.
                        >
                        There is also the general question with date intervals of whether the
                        first day is included in the calculation or not. E.g. work on Monday,
                        Tuesday, Wednesday: that's 3 days service. Put money into the bank on
                        Monday, withdraw it on Wednesday: that's likely to attract 2 days
                        interest.
                        >
                        One needs to understand exactly what calculation is required, and
                        exactly what calculation is provided by the software that is proposed
                        to be used.
                        >
                        HTH,
                        >
                        John
                        What I'm trying to do is adjust date-time stamped file names for date and
                        time errors. The software program collects through a period that roughly
                        coincides with night hours every day and according to the OS clock. It
                        sometimes happens that a user sets the clock to the wrong day or hour,
                        possibly both. Possibly even the month or year. I'm trying to allow a user
                        the opportunity to repair the problem. (Date-time stamp part of the name is
                        yyyymmdd_hhmmss .) Correcting the date needs to be done easily and
                        accurately. For example, if on August 25, he mistakenly sets the date to
                        July 25, and discovers this problem on the real Oct. 5, he should be able to
                        shift all dates from July 25 through Sept. 5 to Aug. 25 through early Oct.,
                        allowing for day oddities in a month during the period. (I hope I got those
                        dates right; otherwise, I think you get the idea. In other words, he needs
                        to shift about 40 days of data to the correct dates.) Or:

                        True calendar period: August 25 to Oct. 5
                        Recorded calendar period: July 25 to Sept. 5 (roughly 5)

                        A second function is to correct the time stamp for drift in the clock. For
                        this, I'm expecting the user knows the daily drift, +/-, in seconds of the
                        clock. When he decides, for example, that he's let the clock drift for more
                        than, say, 120 seconds, he may want to adjust the time stamp for all files
                        collected since the last time he set the clock properly. About the best
                        anyone can hope for is that the data is accurate to within 4 to 5 seconds,
                        so over periods of say a month between adjustments this should be OK. The
                        computers used do not have time data other than that provided by the h/w
                        clock on the computer. This method is not meant to be a cure all, just to
                        get the time stamp within a reasonable value. Personally, I reset the time
                        about every 2-3 weeks. Problems that arise here are associated with working
                        near midnight. Again, it's possible to set some time or date component
                        incorrectly each time one needs to get drift under control.

                        The OSes involved can be Win XP, Win 2000, or even older Win OSes, varieties
                        of Apple and Linux. I don't want to go below the level of the simple h/w
                        clock a typical user might have access to through the OS s/w user interface.
                        However, I do not need to get into OS details to solve the above problems.

                        There are of course times when a mistaken setting is caught early, so the
                        adjustment becomes easy. Suppose the day is taken as May 3 on May 5, and two
                        days later the mistake is noticed. Changing the date for these files is
                        pretty easy (with the program).

                        Well, back to the drawing board for awhile to see how this plays against
                        pyfdate.

                        --
                        W. Watson
                        (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
                        Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

                        Comment

                        • John Machin

                          #13
                          Re: Date Comparison and Manipulation Functions?

                          On Aug 30, 10:41 am, "W. eWatson" <notval...@sbcg lobal.netwrote:
                          What I'm trying to do is adjust date-time stamped file names for date and
                          time errors. The software program collects through a period that roughly
                          coincides with night hours every day and according to the OS clock. It
                          sometimes happens that a user sets the clock to the wrong day or hour,
                          possibly both. Possibly even the month or year. I'm trying to allow a user
                          the opportunity to repair the problem. (Date-time stamp part of the name is
                          yyyymmdd_hhmmss .) Correcting the date needs to be done easily and
                          accurately. For example, if on August 25, he mistakenly sets the date to
                          July 25, and discovers this problem on the real Oct. 5, he should be able to
                          shift all dates from July 25 through Sept. 5 to Aug. 25 through early Oct.,
                          allowing for day oddities in a month during the period. (I hope I got those
                          dates right; otherwise, I think you get the idea. In other words, he needs
                          to shift about 40 days of data to the correct dates.)
                          .... all of which is absolutely nothing to do with your surprise at the
                          result of whatever.plus(m onths=6).

                          So for some period from recorded date X to recorded date Y, the
                          recorded dates of out of kilter by D days. X = Jul 25 2008, Y Sep 5
                          2008, and D is 31 (days from Jul 25 to Aug 25). All you have to do is
                          (pseudocode):

                          if X <= recorded_date <= Y:
                          new_recorded_da te = recorded_date.p lus(days=D)

                          HTH,
                          John

                          Comment

                          • W. eWatson

                            #14
                            Re: Date Comparison and Manipulation Functions?

                            John Machin wrote:
                            On Aug 30, 10:41 am, "W. eWatson" <notval...@sbcg lobal.netwrote:
                            >
                            >What I'm trying to do is adjust date-time stamped file names for date and
                            >time errors. The software program collects through a period that roughly
                            >coincides with night hours every day and according to the OS clock. It
                            >sometimes happens that a user sets the clock to the wrong day or hour,
                            >possibly both. Possibly even the month or year. I'm trying to allow a user
                            >the opportunity to repair the problem. (Date-time stamp part of the name is
                            >yyyymmdd_hhmms s.) Correcting the date needs to be done easily and
                            >accurately. For example, if on August 25, he mistakenly sets the date to
                            >July 25, and discovers this problem on the real Oct. 5, he should be able to
                            >shift all dates from July 25 through Sept. 5 to Aug. 25 through early Oct.,
                            >allowing for day oddities in a month during the period. (I hope I got those
                            >dates right; otherwise, I think you get the idea. In other words, he needs
                            >to shift about 40 days of data to the correct dates.)
                            >
                            ... all of which is absolutely nothing to do with your surprise at the
                            result of whatever.plus(m onths=6).
                            Really? It opened new insights for me. The example above is not the only
                            correction I need to deal with. Further, the author is likely to soon
                            clarify some of the date rules in the tutorial that were not obvious or
                            mentioned there.
                            >
                            So for some period from recorded date X to recorded date Y, the
                            recorded dates of out of kilter by D days. X = Jul 25 2008, Y Sep 5
                            2008, and D is 31 (days from Jul 25 to Aug 25). All you have to do is
                            (pseudocode):
                            >
                            if X <= recorded_date <= Y:
                            new_recorded_da te = recorded_date.p lus(days=D)
                            >
                            HTH,
                            John
                            >

                            --
                            W. Watson
                            (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
                            Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

                            Comment

                            • W. eWatson

                              #15
                              Re: Date Comparison and Manipulation Functions?

                              W. eWatson wrote:
                              John Machin wrote:
                              >On Aug 30, 10:41 am, "W. eWatson" <notval...@sbcg lobal.netwrote:
                              >>
                              >>What I'm trying to do is adjust date-time stamped file names for date
                              >>and
                              >>time errors. The software program collects through a period that roughly
                              >>coincides with night hours every day and according to the OS clock. It
                              >>sometimes happens that a user sets the clock to the wrong day or hour,
                              >>possibly both. Possibly even the month or year. I'm trying to allow a
                              >>user
                              >>the opportunity to repair the problem. (Date-time stamp part of the
                              >>name is
                              >>yyyymmdd_hhmm ss.) Correcting the date needs to be done easily and
                              >>accurately. For example, if on August 25, he mistakenly sets the date to
                              >>July 25, and discovers this problem on the real Oct. 5, he should be
                              >>able to
                              >>shift all dates from July 25 through Sept. 5 to Aug. 25 through early
                              >>Oct.,
                              >>allowing for day oddities in a month during the period. (I hope I got
                              >>those
                              >>dates right; otherwise, I think you get the idea. In other words, he
                              >>needs
                              >>to shift about 40 days of data to the correct dates.)
                              >>
                              >... all of which is absolutely nothing to do with your surprise at the
                              >result of whatever.plus(m onths=6).
                              Really? It opened new insights for me. The example above is not the only
                              correction I need to deal with. Further, the author is likely to soon
                              clarify some of the date rules in the tutorial that were not obvious or
                              mentioned there.
                              >>
                              >So for some period from recorded date X to recorded date Y, the
                              >recorded dates of out of kilter by D days. X = Jul 25 2008, Y Sep 5
                              >2008, and D is 31 (days from Jul 25 to Aug 25). All you have to do is
                              >(pseudocode) :
                              >>
                              >if X <= recorded_date <= Y:
                              > new_recorded_da te = recorded_date.p lus(days=D)
                              >>
                              >HTH,
                              >John
                              >>
                              >
                              >
                              Strange how my post got hooked into this side spur. I'll re-post.

                              --
                              W. Watson
                              (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
                              Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

                              Comment

                              Working...