Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail in 12 hour format #11

Open
josedefreitasc opened this issue Feb 15, 2013 · 0 comments
Open

Fail in 12 hour format #11

josedefreitasc opened this issue Feb 15, 2013 · 0 comments

Comments

@josedefreitasc
Copy link

When i tried to insert an event in a cellphone with the 12 hour format, it doesn`t insert.

I replace this in calendarPlugin.m:
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

for this:

if ([self isHoras]){
    [df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
} else {
    [df setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
}

And add this function:

-(BOOL)isHoras{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setDateStyle:NSDateFormatterNoStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
NSString *dateString = [formatter stringFromDate:[NSDate date]];
NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];
BOOL is24h = (amRange.location == NSNotFound && pmRange.location == NSNotFound);
[formatter release];
NSLog(@"%@\n",(is24h ? @"YES" : @"NO"));
return is24h;
}

finally add in calendarPlugin.h this:

  • (BOOL)isHoras;

Now it works ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant