[darcs-users] example of annotate.py alternative output

Kannan Goundan cakoose at yahoo.com
Mon Mar 21 06:26:14 UTC 2005

> Attached is a patch for a better date format. I used python's 
> strftime with a "%x %X" format which means "locale's date"
> time", so I get 02/28/05 19:57:42 here in the US.
> Modify function pretty_date as you see fit.


> +def pretty_date(date):
> +   import time
> +   return time.strftime("%x %X", time.strptime(date,

Wow.  I didn't know you could do it so easily.

The file I tried it on (DarcsArguments.lhs from darcs-unstable) has
some timestamps that are formatted differently:

   Thu Oct 31 13:29:44 EST 2002

It looks like Darcs doesn't use this format anymore (all the recent
patches use the more compact format).  Here's a modified version of
the function that tries to handle both cases.

I'm not sure why, but the "time.strptime(...)" on my machine doesn't
seem to think 'EST' is a valid time zone.  If I replace it with
'PST', 'PDT', 'UTC' or 'GMT', it works fine.

And I'm really sorry if this message doesn't thread up in the
archives.  Does anyone know how I can get Pipermail/Mailman to thread
my messages properly?  I'm also sorry about the footers -- I really
don't care whether you Yahoo or not.  I need to find a new e-mail

  "%a %b %d %H:%M:%S %Z %Y",
  "%a %b %d %H:%M:%S EST %Y",  # hack hack

def pretty_date(date_string):
   import time
   # Try all the time formats until one works
   for parse_format in INPUT_TIME_FORMATS:
         timestamp = time.strptime(date_string, parse_format)
         return time.strftime("%x %X", timestamp)
      except ValueError:
   # Unable to parse
   #raise ("Couldn't parse '%s'" % date_string)
   return date_string

Do you Yahoo!? 
Make Yahoo! your home page 

More information about the darcs-users mailing list