Closed
Bug 185394
Opened 22 years ago
Closed 21 years ago
Date picker format does not respect local settings
Categories
(Calendar :: General, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: kenn, Assigned: mostafah)
References
Details
Attachments
(5 files, 1 obsolete file)
943 bytes,
patch
|
Details | Diff | Splinter Review | |
2.21 KB,
patch
|
mostafah
:
first-review+
|
Details | Diff | Splinter Review |
1.49 KB,
patch
|
mostafah
:
first-review+
|
Details | Diff | Splinter Review |
2.62 KB,
patch
|
mostafah
:
first-review+
|
Details | Diff | Splinter Review |
3.45 KB,
patch
|
mostafah
:
first-review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.2.1) Gecko/20021130
Build Identifier: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.2.1) Gecko/20021130
Calender uses US date format when setting an appointment, Suggestion, pick up
the date format from the machine default for use in tis section of the program.
It appears to be correct in the preferences section but not when creating
appointments.
Reproducible: Always
Steps to Reproduce:
1. Create new appointment with system set to Australian or English Date format
2.
3.
Actual Results:
Date in appointment is 12/15/2002 (us format)
Expected Results:
Displayed the date format as 15/12/2002 (International Australian/english
Comment 1•22 years ago
|
||
I can also confirm this for the latest builds under XP...
Comment 2•22 years ago
|
||
CONFIRMED:
http://lxr.mozilla.org/mozilla/source/calendar/resources/content/datepicker/datepicker.xml#68
is probably part of the problem.
Comment 3•22 years ago
|
||
Only relief by using ISO 8601 instead of local US.
This method should use dateUtils.js dateFormater.getShortFormatedDate()
instead, but i don't know how to implement it.
Comment 4•22 years ago
|
||
I also don't know how to implement it, but this is a known bug.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 5•22 years ago
|
||
dupe of bug 179102? or vice versa considering that this one has a patch?
Comment 6•22 years ago
|
||
*** Bug 179102 has been marked as a duplicate of this bug. ***
Comment 7•22 years ago
|
||
*** Bug 192545 has been marked as a duplicate of this bug. ***
Updated•22 years ago
|
Summary: Date format for international countries in Calender → Date picker format does not respect local settings
Comment 8•22 years ago
|
||
Same problem under Linux. The current locale should be used.
Comment 9•22 years ago
|
||
*** Bug 197930 has been marked as a duplicate of this bug. ***
Comment 10•21 years ago
|
||
New contact from mikep@oeone.com to mostafah@oeone.com
Filter on string OttawaMBA to get rid of these messages.
Sorry for the spam.
Assignee: mikep → mostafah
Comment 11•21 years ago
|
||
still occurs with
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6a) Gecko/20031001
Comment 12•21 years ago
|
||
This applies to Sunbird as well
Comment 13•21 years ago
|
||
To fix, in the date picker constructor, give it a DateFormater() [sic] :
Mozilla/chrome/calendar/content/datepicker/datepicker.xml:39
+ this.formatter= new DateFormater();
Then in its getPrettyDate method, replace the expression with a call to formatter:
Mozilla/chrome/calendar/content/datepicker/datepicker.xml:78
- return (aValue.getMonth()+1) + "/" + aValue.getDate() + "/" +
aValue.getFullYear();
+ return this.formatter.getShortFormatedDate(aValue);
This fixes it for me (on w2k with control panel / regional options / date set to
yyyy-mm-dd, Moz1.5, 2003092614-cal). If you want, you can get rid of the
getPrettyDate method and call the formatter directly.
(How did I find DateFormater? I searched for "dateFormat" at
http://lxr.mozilla.org/mozilla/ and noticed in the list results that under the
calendar directory in dateUtils.js there is likely sounding DateFormater, so I
tried it out by making the above changes, restarted Mozilla, and it worked. I
wonder if the misspelling has slowed down finding the solution of this bug,
should it be changed to DateFormatter ?)
Comment 14•21 years ago
|
||
Under Linux/ppc, I get the date correctly written (yyyy-mm-dd), but if I modify
it, the change isn't taken into account.
Comment 15•21 years ago
|
||
Ok, here's a function to probe the current date format and parse date accordingly:
Mozilla/chrome/calendar/content/dateUtils.js:284
DateFormater.prototype.parseShortDate = function ( dateString )
{
// probe for date format -- this part could be in constructor
// probe result state:
var parseShortDateRegex = /^\s*(\d+)\D(\d+)\D(\d+)\s*$/; //digits & nonDigits
var parsedYearIndex = -1, parsedMonthIndex = -1, parsedDayIndex = -1;
{ // do probe
var probeDate = new Date(2002,3-1,4); // month is 0-based
var probeString = this.getShortFormatedDate(probeDate);
var probeArray = parseShortDateRegex.exec(probeString);
for (var i = 1; i <= 3; i++) {
switch (Number(probeArray[i])) {
case 2002: case 02: parsedYearIndex = i; break;
case 3: parsedMonthIndex = i; break;
case 4: parsedDayIndex = i; break;
}
}
// all three parsed indexes are now set (no longer -1)
}
// parse dateString
var dateNumbersArray = parseShortDateRegex.exec(dateString);
if (dateNumbersArray != null) {
return new Date(Number(dateNumbersArray[parsedYearIndex]),
Number(dateNumbersArray[parsedMonthIndex]) - 1, // 0-based
Number(dateNumbersArray[parsedDayIndex]));
} else return null; // did not match regex, not a valid date
}
In the definition of the datePicker textBox, replace "new Date(this.value)" with
"new DateFormater().parseShortDate(this.value)".
Mozilla/chrome/calendar/content/datepicker/datePicker.xml:11-13
<xul:textbox id="textbox"
onkeypress="if (event.keyCode == 13) this.parentNode.parentNode.update(new
DateFormater().parseShortDate(this.value));"
onblur="this.parentNode.parentNode.parentNode.parentNode.update(new
DateFormater().parseShortDate(this.value),true);"/>
(If you can figure out how to access this.formatter from this code, you can
avoid creating a new formatter each time.)
Comment 16•21 years ago
|
||
OK, I confirm that works here.
Comment 17•21 years ago
|
||
Comment 18•21 years ago
|
||
Updated•21 years ago
|
Attachment #135273 -
Flags: first-review?(mostafah)
Updated•21 years ago
|
Attachment #135274 -
Flags: first-review?(mostafah)
Assignee | ||
Comment 19•21 years ago
|
||
Comment on attachment 135273 [details] [diff] [review]
part 1 of 2: datepicker.xml changes
Checked into CVS.
Attachment #135273 -
Flags: first-review?(mostafah) → first-review+
Assignee | ||
Comment 20•21 years ago
|
||
Comment on attachment 135274 [details] [diff] [review]
part 2 of 2: dateUtils.js --- parseShortDate
Checked into CVS.
Attachment #135274 -
Flags: first-review?(mostafah) → first-review+
Comment 21•21 years ago
|
||
Fixes to datePicker to restore date after failed parse
(need to set textBox.value property, not attribute).
Also introduced parseTextDate method which reuses this.formatter.
Comment 22•21 years ago
|
||
Fix parseShortDate so if short date format shows 2-digit years, will parse them
as year in interval from 69 previous years to 30 future years
(covers most working people's birthdate, and 30-year mortgages).
Years outside this interval can be specified by typing four digit year.
Comment 23•21 years ago
|
||
Should this bug be marked as FIXED now that the patch has been checked into CVS?
Comment 24•21 years ago
|
||
previous version left out check for 2 digit year < currentYear - 69
Attachment #135364 -
Attachment is obsolete: true
Attachment #135361 -
Flags: first-review?
Attachment #135398 -
Flags: first-review?
Assignee | ||
Comment 25•21 years ago
|
||
Comment on attachment 135361 [details] [diff] [review]
Fix datePicker to restore date after failed parse
Checked into CVS.
Attachment #135361 -
Flags: first-review? → first-review+
Assignee | ||
Comment 26•21 years ago
|
||
Comment on attachment 135398 [details] [diff] [review]
Fix parseShortDate to parse 2-digit years
Checked into CVS.
Attachment #135398 -
Flags: first-review? → first-review+
Comment 27•21 years ago
|
||
Re: comment 22: Windows XP (and possibly other OSes) allows the user to specify
between which dates a two-digit year should be interpreted as. This might
conflict with an internal setting in the calendar.
I don't suppose the calendar could easily query the OS, but I thought it should
be mentioned.
Comment 28•21 years ago
|
||
*** Bug 201116 has been marked as a duplicate of this bug. ***
Assignee | ||
Comment 29•21 years ago
|
||
*** Bug 200887 has been marked as a duplicate of this bug. ***
Assignee | ||
Comment 30•21 years ago
|
||
*** Bug 227038 has been marked as a duplicate of this bug. ***
Comment 31•21 years ago
|
||
Using -
moz 1.5
en-gb locale
en-gb lang
At present ive manually changed datepicker and everything displays correctly -
but if you add an event/task it looks fine but reverses it in the actual
calendar . if you then copy and paste it - it stays where it is .
Comment 32•21 years ago
|
||
The following lines of patch id 135398
http://bugzilla.mozilla.org/attachment.cgi?id=135398&action=view
! if (year < currentYear - 69)
! year += 100;
are currently missing from cvs version according to
http://lxr.mozilla.org/mozilla/source/calendar/resources/content/dateUtils.js#319
(maybe overridden version, id 135364, was merged by mistake?)
Assignee | ||
Comment 33•21 years ago
|
||
Yes that was probably what happened. My fault and my apologies.
Checked the rest into CVS.
Assignee | ||
Comment 34•21 years ago
|
||
The applied patches should've fixed the problem.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Comment 35•20 years ago
|
||
It would be great if we could change the format of the date to overwrite the
local preferences...
(Maybe I should open a new RFE, or maybe it has allready be done, but I've found
nothing)
Comment 36•18 years ago
|
||
The bugspam monkeys have been set free and are feeding on Calendar :: General. Be afraid for your sanity!
QA Contact: gurganbl → general
You need to log in
before you can comment on or make changes to this bug.
Description
•