[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: error in svnClientAdapter command-line xml date parsing.

From: Mark Phippard <MarkP_at_softlanding.com>
Date: 2005-01-06 15:56:14 CET

I want to apply this patch, but I am confused about the comment you added
in the patch:

 + // This formatter uses local timezone, not GMT.

This seems contradictory. Isn't the issue that svn log --xml outputs
dates in GMT, and that is what is passed to the method. Therefore, we
need to tell date formatter that it is getting a date in GMT timezone? If
so, shouldn't the comment say the opposite, that the formatter expects
GMT?

Mark

Jennifer Bevan <jen@alouysius.net> wrote on 01/05/2005 05:31:24 PM:

>
> Hi,
> I believe there is an error in the svnClientAdapter command line xml
date
> parsing. Helper.java (r1184) uses a SimpleDateFormat to parse the XML
> date, but does not set the time zone to be GMT -- but the XML document
> parser converts the log message time (format is HH:mm:ss Z) to GMT.
> So, I kept noticing a double-shift in my reported times. To test, I
> committed
> to my test repository at 1:08pm PST:
>
> jen@bang:/tmp/hello <1113> svn log
> ------------------------------------------------------------------------
> r21 | tester | 2005-01-05 13:08:33 -0800 (Wed, 05 Jan 2005) | 3 lines
>
> But svnClientAdaptor's CmdLineLogMessage.getDate() kept telling
> me that the commit occured at 5:08 AM the next day -- which is
> twice the 8 hour offset. I narrowed it down to the xml parser shifting
> it by 8 hours to GMT, and then Helper.java:convertXMLDate returning
> that time as a local time (9:08pm PST, in my case), which of course
> would then get
> shifted by 8 hours the next time I printed it out as GMT.
>
> So, I have a patch, of course. Now my reported dates match my
> expected dates. Of course, there are some dependency issues here:
> is anyone expecting the date returned in CmdLineLogMessage to
> be a localized date? It would seem like there shouldn't be, but that's
> why I'm posting here...
>
> Thanks,
> Jennifer Bevan
>
> Index: Helper.java
> ===================================================================
> --- Helper.java (revision 1184)
> +++ Helper.java (working copy)
> @@ -35,6 +35,7 @@
> new SimpleDateFormat("yyyy-MM-dd hh:mm:ss Z");
>
> // 2003-10-13T12:54:42.957948Z
> + // This formatter uses local timezone, not GMT.
> private static DateFormat xmlFormat =
> new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
>
> @@ -74,12 +75,15 @@
> }
>
> static Date convertXMLDate(String date) {
> - if (date == null)
> - return null;
> - try {
> - return xmlFormat.parse(date);
> - } catch (ParseException e1) {
> - return null;
> + Date result = null;
> + if (date != null) {
> + try {
> +
> xmlFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
> + result = xmlFormat.parse(date);
> + } catch (ParseException e1) {
> + System.out.println(e1.getMessage());
> + }
> }
> + return(result);
> }
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subclipse.tigris.org
> For additional commands, e-mail: dev-help@subclipse.tigris.org
>
>
>
_____________________________________________________________________________
> Scanned for SoftLanding Systems, Inc. by IBM Email Security Management
> Services powered by MessageLabs.
>
_____________________________________________________________________________

_____________________________________________________________________________
Scanned for SoftLanding Systems, Inc. by IBM Email Security Management Services powered by MessageLabs.
_____________________________________________________________________________
Received on Fri Jan 7 01:56:14 2005

This is an archived mail posted to the Subclipse Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.