jbenet / ios-ntp

SNTP implementation for iOS
http://code.google.com/p/ios-ntp/
MIT License
370 stars 112 forks source link

Network time is incorrect #28

Open huynguyencong opened 9 years ago

huynguyencong commented 9 years ago

When I change my clock forward n minute, the time I receive is forward 2*n minute. The networkTime is double wrong

Ex: If current server time is 15:30. I change my phone time to 15:33. The networkTime I receive from [NetworkClock sharedNetworkClock].networkTime is 15:36

I use it by call [NetworkClock sharedNetworkClock]; in application:didFinishLaunchingWithOptions: and get [NetworkClock sharedNetworkClock].networkTime in a button touch event.

It happen from version: c6f2d2b7054e8f8e1bf2110ec7e384ac0e1c21da Restructure so the NetAssociations tick and hold state as independent…

In correct version, I see networkTime adding has "-" sign: return [[NSDate date] dateByAddingTimeInterval:-timeIntervalSinceDeviceTime/1000.0]; But current version is missed return [[NSDate date] dateByAddingTimeInterval:[self networkOffset]];

huangc10 commented 8 years ago

Thanks for noticing this. It is a bug and can be fixed by adding the ( - ) sign

huynguyencong commented 8 years ago

I created pull request to fix that bug 2 months ago, but the author don't fix that bug, and don't merge this pull request. Because that is critical bug, so I have to create a new open source base on this source, fix this bug, refactor code for more readable and add some new features (block, notification to know when time sync success, save lastest time, property to check network time is synced...).

https://github.com/huynguyencong/NHNetworkTime