calimarkus/JDFlipNumberView

DateCountdownView: showing wrong hours

rafaelgaiaduarte opened this issue · 21 comments

I set the date in method initWithTimeIntervalSince1970. The only thing that is coming wrong is the hour.

All my tries are successful. Could your please tell me more details. Show me your code, describe, which timezone / region settings you are using. Perhaps your timeInterval is just wrong. You could use a more safe method to init the date like:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat: @"dd.MM.yy HH:mm"];
NSDate *date = [dateFormatter dateFromString: @"18.08.12 23:40"];

I'm using the Brazilian timezone GMT -3. I tryed the way you showed, using the method [dateFormatter dateFromString: @"01.01.13 00:00"]; and i'm having the same problem, the hours is 5 hours late than it is supposed to be.

 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
 [dateFormatter setDateFormat: @"dd.MM.yy HH:mm" ];
 NSDate *date = [dateFormatter dateFromString: @"01.01.13 00:00"];

 JDDateCountdownFlipView * countDownFliepView = [[JDDateCountdownFlipView alloc] initWithTargetDate:date];

Well i'm doing no magic. Thats the code:

- (void) setTargetDate: (NSDate*) targetDate
{
    NSUInteger flags = NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
    NSDateComponents* dateComponents = [[NSCalendar currentCalendar] components: flags fromDate: [NSDate date] toDate: targetDate options: 0];

    [...]
}

Perhaps I need to set a timezone on the calendar. But I think it should work. Because [NSDate date] should obviously be in the same timezone, as [NSDate dateWithTimeIntervalSince1970] is.

Also I'm in germany, so I have UTC+1 and everything works correctly..?

I don't get it why is not working.
Thats my code:

-(void)countDown{

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat: @"dd.MM.yy HH:mm" ];
NSDate *date = [dateFormatter dateFromString: @"01.01.13 00:00"];

JDDateCountdownFlipView * countDownFliepView = [[JDDateCountdownFlipView alloc] initWithTargetDate:date];

[self.view addSubview:countDownFliepView];
countDownFliepView.frame = CGRectMake(49, 10, 223, 57);

}

I will keep trying, if i succeed i let you know.

thanks anyway.

Any chance that happened because i converted the project to ARC?

No that also shouldn't be the problem, but you could also just use these non-arc classes in an arc project by using the compiler flag -fobjc-no-arc and leave them as they are.

If I copy/past your code it works perferctly. What exactly is displayed, when you run your code?

I don't know what is happening, but i opened the project today and is working perferctly.

weeeeeell.. that's strange. I'll close the issue for now, as i couldn't reproduce your issue.

The funny thing is that in the morning and at night it works fine, but if i run the project afternoon the hour doesnt work...

If you could create a reoccuring test scenerio, that'd be so great! I cannot reproduce it yet. But that seems like an important bug.

It would be great, if you describe exactly, what date you give in and WHEN you run it and WHAT is displayed then.. is the difference 12 hours, or smth. else?

I will do a screencast and post here, ok?

yes that'd be great!

https://vimeo.com/48023101 the password is rogalabs

Sorry for my bad english. :)

Finally your bug is fixed! It was a stupid mistake within my code. Thanks for your detailed infos!! :) Just get the updated version and you should be fine.

Good, Markus, you are welcome and thanks for fixed the bug.The hour is working correctly, but there is a new bug. The seconds are starting with 99, not 59.

ha! there's some work left..

i have the same issue

yes i will fix this soon! I know what the problem is.

not closed at all, but thats not a very easy fix. I reverted the 'bugfix', as it introduced new bugs. So in master, there is the old version, in the develop branch, there is the 'fixed' version with the new bugs.. I'm still working on a real bugfix. The DateCountdown is just NOT working for now. sorry. You may still use the basic JDFlipNumber view to build your own.

Finally all fixed with a complete rewrite. v2 is available on the develop branch.