[darcs-devel] [patch1623] OldDate belongs to Darcs.Util since it has no patch-related code

Ben Franksen bugs at darcs.net
Sat Oct 21 14:52:26 UTC 2017


Ben Franksen <ben.franksen at online.de> added the comment:

After digging a bit and comparing the OldDate with IsoDate I came to the
following conclusions.

OldDate exports two functions:

(1) showIsoDateTime: This is exactly the same in both versions. So we
can simply replace the one from OldDate with the one from IsoDate.

(2) readUTCDate: This one is different from the one in IsoDate. It can
be re-implemented inside the IsoDate module as:

-- | Similar to 'readUTCDate', except we /ignore/ timezone info
-- in the input string. This is incorrect and ugly. The only reason
-- it still exists is so we can generate file names for old-fashioned
-- repositories in the same way that old darcs versions expected them.
-- You should not use this function except for the above stated purpose.
readUTCDateOldFashioned :: String -> CalendarTime
readUTCDateOldFashioned d = 
             case parseDate 0 d of
             Left e -> error $ "bad date: "++d++" - "++show e
             Right ct -> (unsafeToCalendarTime ct) { ctTZ = 0 }

I propose we add this function to IsoDate and use it (only) in the
D.P.Info.makeFilename so as not to break reading old repos from before
2003-11. After this change OldDate is obsolete and can be removed.

The readUTCDate from IsoDate does the right thing for all purposes
except the above mentioned 'makeFilename': it correctly translates
localized date strings (i.e. which contain timezone info) to UTC. So the
change in the output of 'darcs log' that you noticed is actually a bug
fix. Let's look at the first patch ever in the darcs darcs repo.

Previously we got:

ben at yuiitsu[1]:.../darcs/screened>/usr/bin/darcs log -p'Initial version'
| grep Date
Date:   Sun Oct 20 22:01:05 CEST 2002

This is displaying the date/time in my timezone (CEST).

Now look at what's in the patch itself:

ben at yuiitsu[1]:.../darcs/current>zcat
_darcs/patches/0000083540-38ca098770c137ea479b46a1cf64278373e18d3de1f2419ab552b3c0845efb4e
| head -3
[Initial version of darcs.
droundy at abridgegame.org**Sun Oct 20 20:01:05 EDT 2002] addfile ./Add.lhs
hunk ./Add.lhs 1

So let us display the patch using the original timezone:

ben at yuiitsu[1]:.../darcs/screened>TZ='America/New_York' /usr/bin/darcs
log -p'Initial version' | grep Date
Date:   Sun Oct 20 16:01:05 EDT 2002

This is plainly wrong. Whereas with the change:

ben at yuiitsu[1]:.../darcs/screened>TZ='America/New_York' darcs log
-p'Initial version' | grep Date
Date:   Sun Oct 20 20:01:05 EDT 2002

which is the correct date/time when the patch was recorded.

I have attached another bundle that makes the changes I propose above.

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/patch1623>
__________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: remove-darcs_util_olddate.dpatch
Type: application/x-darcs-patch
Size: 21637 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/darcs-devel/attachments/20171021/4b55a721/attachment-0001.bin>


More information about the darcs-devel mailing list