cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Grebnov (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CB-6132) Globalization plugin method getDatePattern always returns short date style on iOS.
Date Wed, 13 Jan 2016 10:04:40 GMT

     [ https://issues.apache.org/jira/browse/CB-6132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sergey Grebnov updated CB-6132:
-------------------------------
    Labels: ios triaged  (was: )

> Globalization plugin method getDatePattern always returns short date style on iOS.
> ----------------------------------------------------------------------------------
>
>                 Key: CB-6132
>                 URL: https://issues.apache.org/jira/browse/CB-6132
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Globalization
>    Affects Versions: 3.4.0
>         Environment: iOS 7
>            Reporter: Alan Rahlf
>              Labels: ios, triaged
>
> Here are a few examples to demonstrate the problem:
> {code}
> navigator.globalization.getDatePattern(function(properties) {
>     console.log('pattern: ' + properties.pattern); // prints "M/d/yy"
> }, function() {}, { formatLength: 'short', selector: 'date' });
> navigator.globalization.getDatePattern(function(properties) {
>     console.log('pattern: ' + properties.pattern); // prints "M/d/yy"
> }, function() {}, { formatLength: 'medium', selector: 'date' });
> navigator.globalization.getDatePattern(function(properties) {
>     console.log('pattern: ' + properties.pattern); // prints "M/d/yy"
> }, function() {}, { formatLength: 'long', selector: 'date' });
> navigator.globalization.getDatePattern(function(properties) {
>     console.log('pattern: ' + properties.pattern); // prints "M/d/yy"
> }, function() {}, { formatLength: 'full', selector: 'date' });
> {code}
> As you can see, the pattern is the same for all format lengths.  This is happening because
in the iOS plugin code it's iterating over the options dictionary keys, but because order
matters, the logic inside the loop is flawed.  Here's the block I'm referring to:
> {code}
> if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
>     NSEnumerator* enumerator = [items keyEnumerator];
>     id key;
>     // iterate through all the options
>     while ((key = [enumerator nextObject])) {
>         id item = [items valueForKey:key];
>         // make sure that only string values are present
>         if ([item isKindOfClass:[NSString class]]) {
>             // get the desired format length
>             if ([key isEqualToString:@"formatLength"]) {
>                 if ([item isEqualToString:@"short"]) {
>                     style = kCFDateFormatterShortStyle;
>                 } else if ([item isEqualToString:@"medium"]) {
>                     style = kCFDateFormatterMediumStyle;
>                 } else if ([item isEqualToString:@"long"]) {
>                     style = kCFDateFormatterLongStyle;
>                 } else if ([item isEqualToString:@"full"]) {
>                     style = kCFDateFormatterFullStyle;
>                 }
>             }
>             // get the type of date and time to generate
>             else if ([key isEqualToString:@"selector"]) {
>                 if ([item isEqualToString:@"date"]) {
>                     dateStyle = style;
>                     timeStyle = kCFDateFormatterNoStyle;
>                 } else if ([item isEqualToString:@"time"]) {
>                     dateStyle = kCFDateFormatterNoStyle;
>                     timeStyle = style;
>                 } else if ([item isEqualToString:@"date and time"]) {
>                     dateStyle = style;
>                     timeStyle = style;
>                 }
>             }
>         }
>     }
> }
> {code}
> The selector key runs first, which relies on the style variable being set correctly,
but this doesn't get set until the 2nd iteration of the loop when the formatLength key is
evaluated.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message