Date format on print pages only US format, locale or LC_TIME not honored? Suggested solution and ref's included.

RESOLVED DUPLICATE of bug 231280

Status

()

Core
Printing: Output
--
minor
RESOLVED DUPLICATE of bug 231280
16 years ago
14 years ago

People

(Reporter: Eric Maryniak, Assigned: rods (gone))

Tracking

Trunk
mozilla1.3alpha
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

16 years ago
When printing, in the default setup (File|Page Setup, Margins & Header/Footer),
the Date/Time (right-bottom) seems to always be printed in the US format, i.e.
MM/DD/YY HH:MM. The locale setting, or LC_TIME specifically, does not seem to
influence this. Moreover, sometimes one wishes to override the locale setting
of date/time for printed out web pages (or, e.g., just have the date and not
the time).
Ideally, instead of just being able to set "Date/Time" in the Page Setup, one
should also be able to supply a format string, just as in ProFTPd's config's
setup, which can be passed right away to strftime(), e.g.:

    %{%Y-%m-%d %H:%M:%S}t   - ISO 8601 form, e.g.: 2000-02-29 14:42:42
    %{%m/%d/%Y %H:%M:%S}t   - US form, e.g.: 02/29/2000 14:42:42
    %{%d-%m-%Y %H:%M:%S}t   - European (not all countries): 29-02-2000 14:42:42

(A suitable place would be to put in this in "Custom...")?
Or, alternatively, one might add a small number of additional Date/Time
formats (in addition to Title, Url etc.) in the setup box, for example:

    Date/Time ISO - ISO 8601 format (YYYY-MM-DD HH:MM, time 24h form, 00-23!).
    Date/Time US  - US format (and please make it YYYY instead of just YY!)
    Date/Time EUR - European format (usually DD-MM-YYYY, note "-", not "/")

It's just a minor issue, but adds usability for (e.g.) European users. URL's:

o ProFTPd's Date/Time configurationability (www.proftpd.org, GPLed software):
    http://proftpd.linux.co.uk/localsite/Userguide/linked/config_ref_LogFormat.html

o ISO 8601 Date/Time standard format:
    http://www.cl.cam.ac.uk/~mgk25/iso-time.html

Comment 1

16 years ago
I have no problems as german User. Date/Time is de_de (DD.MM.YYYY HH:MM - 24h)
at Print-PreviewPage and on Print-Page (W2K, Gecko/2002071408).
(Reporter)

Comment 2

16 years ago
Hmm. Could it be version or OS related?
I'm using SuSE Linux 8.0 with Mozilla "Build ID: 2002061910-SuSE"?
(Assignee)

Comment 3

16 years ago
Here is how I am getting the format for the the Date/Time String:
    // Create current Date/Time String
    nsresult rv;
    nsCOMPtr<nsILocale> locale; 
    nsCOMPtr<nsILocaleService> localeSvc = do_GetService(kLocaleServiceCID, &rv);
    if (NS_SUCCEEDED(rv)) {
      rv = localeSvc->GetApplicationLocale(getter_AddRefs(locale));
      if (NS_SUCCEEDED(rv) && locale) {
        nsCOMPtr<nsIDateTimeFormat> dateTime;
        rv = nsComponentManager::CreateInstance(kDateTimeFormatCID,
                                               NULL,
                                               NS_GET_IID(nsIDateTimeFormat),
                                               (void**) getter_AddRefs(dateTime));
        if (NS_SUCCEEDED(rv)) {
          nsAutoString dateString;
          time_t ltime;
          time( &ltime );
          if (NS_SUCCEEDED(dateTime->FormatTime(locale, kDateFormatShort,
                           kTimeFormatNoSeconds, ltime, dateString))) {
            PRUnichar * uStr = ToNewUnicode(dateString);
            SetDateTimeStr(uStr); // memory will be freed
          }
        }
      }
    }

Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Target Milestone: --- → mozilla1.1alpha
(Assignee)

Comment 4

16 years ago
I think the prblem lies in the OS version, we can morph this bug to an
Enhancement request for the user being able to specifiy/override the default
localized format. 

This could be done in the PageSetup dialog, with a combobox enabling the
following options:
Default (default localized - what is done right now)
ISO - ISO 8601 format 
US format 
European format
rods: You don't want to get the locale, just pass nsnull in as the first param
to ->FormatTime.

See http://bugzilla.mozilla.org/show_bug.cgi?id=38014#c26 - I had this problem
with ftp, and smfr helped me out.

IIRC, the problem is that the string representing the current global locale
doesn't mean that the datetime format is set to be the defaults for that locale,
or something like that.

reporter, what is the output from teh |locale| command from a terminatl window?
(Reporter)

Comment 6

16 years ago
> reporter, what is the output from teh |locale| command from a terminatl window?

Originally, it was indeed US:
$ locale
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE=POSIX
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=

But I also tried "nl_NL" (Dutch), "C" and "POSIX", i.e. I did a
'export LC_TIME="nl_NL" (and ditto for all LC_*), and restarted mozilla.
Same result.
However, as said, I would like to be able to specify a Date/Time format,
irrespective of the current locale, e.g. because I just want the Date on
my printout, or the Date and Time upto and including the second etc.,
or the Date on one corner and the Time on another, etc.
Imho, specifying (under Custom...) the strftime() format string, a la

    %{%Y-%m-%d %H:%M:%S}t

(see man strftime()), would be the most cool!

(One might consider other %var's, too, %h (hostname), %u (username) and %i
 (internet address) come to mind, but I should stop now! :-)
see also bug 140814

Comment 8

16 years ago
Same problem under MacOS. Moz doesn't respect the Date & Time setting.
(Assignee)

Updated

15 years ago
Target Milestone: mozilla1.1alpha → mozilla1.2beta

Comment 9

15 years ago
This problem also affects Mac OS X.
Keywords: mozilla1.2
OS: Linux → All
Hardware: PC → All
(Assignee)

Updated

15 years ago
Target Milestone: mozilla1.2beta → mozilla1.3alpha

Updated

15 years ago
Keywords: mozilla1.2 → mozilla1.3
(Reporter)

Comment 10

15 years ago
In Mozilla 1.4b it seems to be fixed by using the following 'hack', 
see the below mentioned Debian docu/url. 
In a nutshell, use 'English in Denmark' (!!) ('$ ' = bash prompt): 
 
$ LC_TIME=en_DK /path/to/mozilla 
 
Mozilla will then print YYYY-MM-DD HH:MM dates. 
 
Example wrapper script for Mozilla: 
 
---cut: mozilla wrapper, e.g. /usr/bin/mozilla--- 
#!/bin/sh 
 
mozilla_bin=/usr/local/mozilla/mozilla 
 
# Hack: using LC_TIME=en_DK (English in Denmark) results in ISO 8601 
#       dates when printing in Mozilla 1.4b: YYYY-MM-DD HH:MM 
# 
# From http://www.debian.org/doc/manuals/reference/ch-tune.en.html : 
#     ... 
#     9.7.5 ISO 8601 date format locale 
#           The locale support for the international date standard of 
#           yyyy-mm-dd (ISO 8601 date format) is provided by the locale 
#           called en_DK, - English in Denmark which is a bit of joke :-) 
#           ... 
 
if [ -f $mozilla_bin -a -x $mozilla_bin ]; then 
    export LC_TIME=en_DK 
    exec $mozilla_bin 
else 
    echo "no mozilla program: $mozilla_bin" 
fi 
---cut--- 
Status: ASSIGNED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → WORKSFORME
(Reporter)

Comment 11

14 years ago
Somehow the 'hack':
    export LC_TIME=en_DK 
does not work anymore: I get US date/time format when printing
no matter how I set LANG or locale's.
Has the locale handling changed in Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.4.1) Gecko/20031114?
Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---
This problem was discovered, solved and verified on Mac OS X. All builds after
and including 2004-02-16 should have the fix. Please, let me know if the problem
still persists. The key to the solution is in the 5th comment (Comment 5) of
this bug. 

*** This bug has been marked as a duplicate of 231280 ***
Blocks: 231757
Status: REOPENED → RESOLVED
Last Resolved: 15 years ago14 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.