[Zope] Re: formatted date anomaly ...

Jim Sanford jsanford@atinucleus.com
Tue, 8 Feb 2000 07:04:57 -0600


From what I understand the C style formatting (%Y) returns GMT I get around this with a kludge

I have a method at the top of my site called DisplayDateTime:

<dtml-if "dtvar.strftime('%m/%d/%Y')=='02/05/2036'">
<dtml-if "dfmt==1">
<dtml-var "'  /  /   00:00:00'">
<dtml-elif "dfmt==2">
<dtml-var "'  /  /   '">
<dtml-else>
<dtml-var "'  /  /   00:00:00'">
</dtml-if>
<dtml-else>
<dtml-if "dfmt==1">
<dtml-var dtvar fmt=mm>/<dtml-var dtvar fmt=dd>/<dtml-var dtvar fmt=year> <dtml-var dtvar fmt=AMPMMinutes>
<dtml-elif "dfmt==2">
<dtml-var dtvar fmt=mm>/<dtml-var dtvar fmt=dd>/<dtml-var dtvar fmt=year>
<dtml-else>
<dtml-var dtvar fmt=mm>/<dtml-var dtvar fmt=dd>/<dtml-var dtvar fmt=year> <dtml-var dtvar fmt=AMPMMinutes>
</dtml-if>
</dtml-if>


I call it like this:

<dtml-var "DisplayDateTime(_.None,_,dtvar=ZopeTime().toZone('US/Central'),dfmt=1)"> or
<dtml-var "DisplayDateTime(_.None,_,dtvar=SQL_query_datefield,dfmt=1)">



dfmt 1=date and time (12 hour clock) dfmt 2 - date only.
The check for the 2-5-2036 date catches empty dates (Zope returns that year for an empty date when using strftime - with no
formatting Zope returns 12-30-1899 for an empty data.)

----- Original Message -----
From: Darran Edmundson <Darran.Edmundson@anu.edu.au>
To: zope <zope@zope.org>
Sent: Tuesday, February 08, 2000 6:18 AM
Subject: [Zope] Re: formatted date anomaly ...


I discovered the source of my problem with formatted
dates.  To recap, create a DTML *document* with the
following code:

  <dtml-var standard_html_header>
  <dtml-var mydate><br>
  <dtml-var mydate fmt="%Y"><br>
  <dtml-var mydate fmt="%d/%m/%Y - %H:%M">
  <dtml-var standard_html_footer>

Now add a property to this document (not possible for
methods) called "mydate", make it of type "date" and
enter the date value "01/01/2000".  Try rendering the
document by selecting the View tab.  On my machine
I see the following:

   2000/01/01
   1999
   31/12/1999 - 14:00

Zope with no formatting assumes the date I entered is
in local time.  Add formatting however and the date is
now assumed to be GMT.  Since Zope obviously knows my
timezone, why not maintain consistency by assuming that
dates are to be rendered in the same time zone that
they were inputted?

At this late hour I cannot see the rationale for this.  Could
someone please enlighten me.

Cheers,
Darran.


_______________________________________________
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )