This snapshot of some Playground code shows my attempt to adjust an NSDate by nanoseconds, followed by trying to get the same value of nanoseconds by comparing the first NSDate with the second NSDate:
Given all the stuff about floating-point numbers and decimal inaccuracy, I can see that using NSTimeInterval
may not be the way to do this.
Another possibility would be using NSDateComponents
, I think. The whole process is really confusing to me though. It seems like you have to create a gregorian calender object, then get the nanoseconds into it from the NSDate
somehow, then adjust the nanonseconds directly and get it all back into an NSDate
again. Very complicated!
But since NSCalendar
has a built-in way for storing nanoseconds as Ints
I suppose I really need clarification on whether or not it can be used reliably for this purpose.