Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3742] Android: Date toLocaleString Doesn't Respect 24-hour Format

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-06-22T12:37:00.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sSprint 2011-25, Release 1.8.0
ComponentsAndroid
Labelsn/a
ReporterDawson Toth
AssigneeNatalie Huynh
Created2011-04-26T11:00:03.000+0000
Updated2011-08-25T11:02:48.000+0000

Description

The Problem

On Android, the JavaScript "Date" object's "toLocaleString" function doesn't respect the "Use 24-hour format" setting in the "Date & time settings".

Code Sample

For example, place the following in an app.js. * It will create a new Date on October 1st, 2011 at 1pm. * Go in to the device's Settings app, then Date & time settings, and check "Use 24-hour format". * When you run the app, it will alert if the first 2 characters of theDate.toLocaleString() are 13, and thus if the 24-hour format is being used.
var time = new Date(2011, 10, 1, 13, 0, 0).toLocaleTimeString();
var is24HourTime = time.substring(0, 2) == '13';
alert(time + ': Is 24 Hour Time? ' + (is24HourTime ? 'Yes!' : 'No...'));

Associated Helpdesk Ticket

http://appc.me/c/WPP-21246-756

Attachments

FileDateSize
TIMOB-3742.js2011-06-21T14:10:14.000+0000934

Comments

  1. Marshall Culpepper 2011-06-21

    Run the attached manual test case to verify this fix works
  2. Bill Dawson 2011-06-22

    https://github.com/appcelerator/titanium_mobile/pull/139 was merged. No 1.7.2 label is on this, so resolving.
  3. Natalie Huynh 2011-08-25

    Tested with 1.8.0.v20110819142548 iPhone 4.3.4 iPad2 4.3.2 Motorola Xoom 3.2 Nexus One 2.2.2

JSON Source