mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-16 08:31:26 +00:00
34 lines
1.0 KiB
Objective-C
34 lines
1.0 KiB
Objective-C
#import "SWGDate.h"
|
|
|
|
@implementation SWGDate
|
|
|
|
@synthesize date = _date;
|
|
|
|
- (id) initWithValues:(NSString*)input {
|
|
if([input isKindOfClass:[NSString class]]){
|
|
NSDateFormatter* df = [NSDateFormatter new];
|
|
NSLocale *locale = [[NSLocale new]
|
|
initWithLocaleIdentifier:@"en_US_POSIX"];
|
|
[df setLocale:locale];
|
|
[df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"];
|
|
|
|
_date = [df dateFromString:input];
|
|
}
|
|
else if([input isKindOfClass:[NSNumber class]]) {
|
|
NSTimeInterval interval = [input doubleValue];
|
|
_date = [[NSDate alloc] initWithTimeIntervalSince1970:interval];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(NSString*) toString {
|
|
NSDateFormatter* df = [NSDateFormatter new];
|
|
NSLocale *locale = [[NSLocale new]
|
|
initWithLocaleIdentifier:@"en_US_POSIX"];
|
|
[df setLocale:locale];
|
|
[df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"];
|
|
|
|
return [df stringFromDate:_date];
|
|
}
|
|
|
|
@end |