Closed Bug 270724 Opened 20 years ago Closed 20 years ago

Parses PM time as AM if format has leading tt or non AM/PM, as in taiwan locale tt hh:mm:ss

Categories

(Calendar :: Sunbird Only, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: gekacheka, Assigned: mostafah)

References

Details

Attachments

(2 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: 

As reported by Rupert Li in bug 249824 comment 7 and bug 249824 comment 9

Parses pm time as am time if format has leading tt or non AM/PM tt, as in taiwan
locale tt hh:mm:ss

Diagnosis: parseTimeOfDay currently assumes that tt produces a varation of AM or
PM and is always after the time.  Needs to be generalized to accept tt before
the time, and to parse other tt strings such as 上午 and 下午 (zh-TW) and 午前
and 午後 (ja-JP).  Probably best approach is to derive the strings in the
constructor by formatting sample times and parsing the strings from the
formatted times.

Reproducible: Always
Steps to Reproduce:
tt before:
1. Set OS time format to "tt hh:mm:ss"
2. try to enter a PM time in a new event dialog time picker

Actual Results:  
Parsed as AM time.

Expected Results:  
Parsed as PM time.
(to apply: patch -p 2 -i file.patch )

This patch extends the constructor to parse an AM time and PM time to discover
the AM/PM strings for the current O.S. time format.

The AM/PM strings are incorporated into the parseTimeRegExp, because the exact
string is needed to tell whether the character following the digits is a
separator, units character, or the first character of the am/pm string.

The AM/PM may now appear either before or after the digits.

In addition to the strings parsed from the current O.S. format, standard
international formats are parsed for A.M. and P.M. in roman or cyrillic
letters, or chinese/kanji characters.  (This covers most of the U.N. languages,
English, French, Spanish, Russian, Chinese, but not Arabic unless it also uses
roman AM/PM.  It covers the G8 languages English, French, German, Italian,
Japanese, Russian.)
As in comment #1, with minor changes to avoid strict javascript error, and to
name constant RegExp index values to clarify code.
Attachment #167504 - Attachment is obsolete: true
Comment on attachment 167590 [details] [diff] [review]
dateUtils.js patch: parse current format for AM and PM strings, add them to RegExp, allow am/pm before as well as after digits

Can verify standard formats as follows:

Open new event dialog.

For each of the following strings, pasting it into the start time field and
pressing tab should parse as 9 in the morning (09:00) or minutes after.

   9am
   9:01 A M
   a.m. 9:02
   AM9:03
   9:04ам
   9:05АМ
   上午9:06
   午前9:07

For each of the following strings, pasting it into the start time field and
pressing tab should parse as 3 in the afternoon (15:00) or minutes after.

   3pm
   3:01 P M
   p.m. 3:02
   PM3:03
   3:04рм
   3:05РМ
   下午3:06
   午後3:07
Attachment #167590 - Flags: first-review?(mostafah)
Comment on attachment 167590 [details] [diff] [review]
dateUtils.js patch: parse current format for AM and PM strings, add them to RegExp, allow am/pm before as well as after digits

Checked in. Thanks.
I just have to trust gekacheka on this one. It's too complex to get into
details with. Hopefully he'll be available if anything comes up.
Attachment #167590 - Flags: first-review?(mostafah) → first-review+
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
(patch -p 2 -i file.patch)

Add Arabic am (ص) and pm (م) to complete coverage of AM/PM for UN languages
and G8 languages.  Document coverage.

Since it is a right-to-left script, I found that on w2k I had to type/paste the
arabic letter on the left of the number in the field for it to appear on the
right and be parsed.
Comment on attachment 167835 [details] [diff] [review]
dateUtils.js patch: complete the AM/PM coverage for UN & G8 languages, doc

Checked in. Many thanks
Attachment #167835 - Flags: first-review+
*** Bug 282110 has been marked as a duplicate of this bug. ***
The bugspam monkeys have been set free and are feeding on Calendar :: Sunbird Only. Be afraid for your sanity!
QA Contact: gurganbl → sunbird
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: