Created
August 14, 2012 06:09
-
-
Save Me1000/3346813 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| #define SECOND_INTERVAL 1 | |
| #define MINUTE_INTERVAL SECOND_INTERVAL * 60 | |
| #define HOUR_INTERVAL MINUTE_INTERVAL * 60 | |
| #define DAY_INTERVAL HOUR_INTERVAL * 24 | |
| #define WEEK_INTERVAL DAY_INTERVAL * 7 | |
| int main(int argc, char *argv[]) { | |
| NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init]; | |
| NSDate *now = [NSDate date]; | |
| NSInteger time = (NSInteger)[now timeIntervalSinceReferenceDate]; | |
| NSInteger mod = time % DAY_INTERVAL; | |
| NSInteger expectedValue = (NSInteger)[now timeIntervalSinceReferenceDate]; | |
| while (expectedValue - DAY_INTERVAL >= 0) | |
| expectedValue -= DAY_INTERVAL; | |
| NSLog(@"Day: %d", DAY_INTERVAL); | |
| NSLog(@"Time: %d", time); | |
| NSLog(@"Modded value: %d", mod); | |
| NSLog(@"Loopy value: %d", expectedValue); | |
| NSLog(@"Is this right? %@", expectedValue == mod ? @"Why yes, yes it is..." : @"Nope, magic C things are breaking!"); | |
| [p release]; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yep, good call. Defines were easier for terrible prototyping :)