John Machin <sj..con.net> wrote: >On Aug 30, 10:41 am, "W. eWatson" <notval....cglobal.net> wrote: > >> 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(months=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_date = recorded_date.plus(days=D) >
This will work nicely for negative values of D. The case of positive D values is more of a toffee: Its Wednesday and I make some observations. Its Thursday and I "fix" my clock - system thinks its Wednesday again. I make some observations - Either overwriting or adding to the original Wednesdays stuff. Its Friday and I spot the error - my D value is 1 day. I need to split the "Wednesday" file into two bits, if I can, and apply the correction to the second half, else I will have a gap for Wednesday. Depending on how the logging is done, it may be an unchewable toffee. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list