Created
October 5, 2012 09:29
-
-
Save eienf/3838919 to your computer and use it in GitHub Desktop.
Print all era in Japanese Calendar.
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> | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool { | |
NSCalendar *japanese = [[NSCalendar alloc] initWithCalendarIdentifier:NSJapaneseCalendar]; | |
NSLocale *aLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; | |
NSDateComponents *comps = [[NSDateComponents alloc] init]; | |
comps.year = 1; | |
comps.month = 12; | |
comps.day = 31; | |
for (comps.era = 235; comps.era >= 0; comps.era--) { | |
NSDate *aDate = [japanese dateFromComponents:comps]; | |
NSDateFormatter *aFormatter = [[NSDateFormatter alloc] init]; | |
aFormatter.calendar = japanese; | |
aFormatter.locale = aLocale; | |
aFormatter.dateFormat = @"G y/M/d"; | |
NSLog(@"%@",[aFormatter stringFromDate:aDate]); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment