Re: FW: This week's Q&A

Hello Richard, Lloyd, others,

A few comments below. Overall, quite good!

At 19:04 03/05/28 +0100, Richard Ishida wrote:

>From: Lloyd Honomichl [mailto:lloyd@honomichl.com]
>Sent: 26 May 2003 17:11
>To: ishida@w3.org
>Subject: Re: This week's Q&A
>
>
>Sorry about the delay.  I missed the last call due to the arrival of
>grandchild number 2.  Besides, I should get some extra slack since
>today is a holiday in the U.S. - Memorial Day.
>
>In any case here's my Q&A:
>
>Question:
>
>How do I handle date formatting in my web pages?

Do we want to say 'date formatting', which implies an active
process, or could we ask 'how to format dates', which is
more about the end result?


>Answer:
>
>For static web pages there is no ideal solution.  It would be nice if
>there was
>some sort of <DATE> tag that would display dates according the locale
>of the
>user agent, but no such tag exists.

I'm not completely sure this would be an ideal solution. I have a
Japanese system with lots of English applications. I would hate
to see an English date format in a Japanese Web page, and I would
hate to see a Japanese date format in an English Web page.


>It is common to change date formats during localization of the pages,
>but this is
>not a complete solution.  English is spoken in both the U.S. and the
>U.K. but they
>use different date formats, so the language of the document is not
>sufficient to
>determine the format for dates.  Multi-lingual users may potentially be
>
>confused
>by date formats as well.

I would reduce the 'may potentially' to 'will'. Web pages are looked
at by people from all over the world.


>If a native Japanese speaker is reading an
>English web
>page from a web site in Germany that contains the date 03/04/02 how
>will they
>react?

Better to change 'how will they react' to something more specific.



>In such cases, it is important to use an unambiguous format.  Using ISO
>
>8601 is
>one approach.  2003-04-02

I think at this point, the reader needs to be told that 2003-04-02
is ISO 8601.

>is somewhat clearer than 03/04/02.  Using an
>abbreviation for the month makes it even more clear:  2003-Apr-02.

Why not just write "April 2nd, 2003"? That's much more readable. Also,
assuming it is an US site, it is easiest to parse for US readers,
who are probably the main target, while still unambiguous for others.

Maybe we have to distinguish between dates in text and dates in
tables (for the later, space considerations may be important).
But then again, there are many cases in between.


>For dynamically generated web pages you can use the HTTP_ACCEPT_LANGUAGE
>header

The HTTP header is "Accept-Language". "HTTP_ACCEPT_LANGUAGE" is the
variable name that is used in CGI scripts to reflect that header.


>to control which date format is used.

This may be read as saying that if you get Accept-Language: en-us,
then using 04/02/03 is okay. I would have to disagree with this;
I think building in a bit of redundancy is important because too
many things can go wrong (browser settings, fallbacks,...).
We should make clear that redundancy is always desirable.


>A
>full
>discussion of how to do this would be too large for this document, but
>here are
>pointers for some common environments.
>
>Java/JSP:  Call the getLocale method of the ServletRequest or
>HttpServletRequest object.  Use the returned Locale object to call
>DateFormat.
>
>ASP: Use Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") to get the
>users preferences.  Parse the first locale from the list of accepted
>locales.  You'll
>have to do your own mapping from the alphabetic locale code to a numeric
>Locale Identifier.  Set Session.LCID to the resulting value.  Call
>FormatDateTime
>to format the date.
>
>Perl: Use $ENV{'HTTP_ACCEPT_LANGUAGE'} to get the preferred language.
>Use POSIX:strftime to format date values.  You'll have to do your own
>mapping
>of the accepted langauges value to a date format string.
>
>
>Remember, even if you use one of these methods for formatting the date,
>choose an unambiguous  date format to avoid the sort of problems
>mentioned
>above.   For Java avoid the SHORT format, which uses only numbers.  For
>
>ASP
>use vbLongDate.

Yes, this is exactly what I was looking for. But the ghist of it
should be mentioned a bit earlier.

Regards,   Martin.



>References:
>
>http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/
>ServletRequest.html
>http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html
>
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
>script56/html/vsfctformatdatetime.asp
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
>iisref/htm/internationalclients.asp
>
>
>
>On Friday, May 23, 2003, at 01:39  AM, Richard Ishida wrote:
>
> > Hi Lloyd,
> >
> > I think you were due to submit a question this week for review by
> > email.
> > Do you have something ready?
> >
> > Cheers,
> > RI
> >
> > ============
> > Richard Ishida
> > W3C
> >
> > tel: +44 1753 480 292
> > http://www.w3.org/International/ http://www.w3.org/People/Ishida/
> >
> >
> >

Received on Friday, 30 May 2003 14:44:13 UTC