[Zope3-dev] Re: mini-RFC: times and timezones

Derrick Hudson dman at dman13.dyndns.org
Sat Feb 26 13:33:38 EST 2005


On Sat, Feb 26, 2005 at 03:18:30AM +0200, Marius Gedminas wrote:
| On Wed, Feb 23, 2005 at 10:26:42PM -0500, Gary Poster wrote:
| <snip list of suggestions>
| >   * Views should generally display dates (stored with a UTC timezone)  
| > using something like this:
| >         formatter = request.locale.dates.getFormatter('dateTime', length='short')
| >         tz = zope.interface.common.tzinfo.ITZInfo(request)
| >         return formatter.format(zope.i18n.switchTimeZones(date, tz)
| 
| This looks like a mouthful.  Can we invent an obvious way to display
| dates and times without having to remember weird three-line
| incantations?  (Can anyone remember how to open a text file in Java
| without looking it up?)

    InputStream stream ;
    try 
        {
        stream = new java.io.FileInputStream( "/path/to/file" ) ;
        }
    catch (IOException err)
        {
        throw new RuntimeException(err) ;
        }

Sorry, I do a lot of Java at work.  However, you are right that Java's
I/O API is overly cumbersome to work with.  

How about
    s = zapi.dateformatshort(request, date)
?

def dateformat(request, date, length) :
    formatter = request.locale.dates.getFormatter('dateTime',  length)
    tz = zope.interface.common.tzinfo.ITZInfo(request)
    return formatter.format(zope.i18n.switchTimeZones(date, tz)

def dateformatshort(request, date) :
    return dateformat(request, date, 'short')

def dateformatlong(request, date) :
    return dateformat(request, date, 'long')


[...]
| Storing dates in UTC and converting to some other timezone on
| display is the way to go.

I agree with this.

-D

-- 
Contrary to popular belief, Unix is user friendly.
It just happens to be selective about who it makes friends with.
                                               -- Dave Parnas
 
www: http://dman13.dyndns.org/~dman/            jabber: dman at dman13.dyndns.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20050226/e05028bc/attachment.bin


More information about the Zope3-dev mailing list