Skip to content

Instantly share code, notes, and snippets.

@Me1000
Created August 14, 2012 06:09
Show Gist options
  • Select an option

  • Save Me1000/3346813 to your computer and use it in GitHub Desktop.

Select an option

Save Me1000/3346813 to your computer and use it in GitHub Desktop.
#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];
}
@Me1000

Me1000 commented Aug 14, 2012

Copy link
Copy Markdown
Author

Yep, good call. Defines were easier for terrible prototyping :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment