ResKnife/NuTemplateEditor/ElementDATE.m
Nicholas Shanks fee2452785 Allow the rebase of foreign repositories onto master.
Restores the NuTemplateEditor directory deleted from Git but not from SVN. Foreign repos were forked from SVN tree
2014-02-20 00:53:03 +00:00

65 lines
2.9 KiB
Objective-C

#import "ElementDATE.h"
@implementation ElementDATE
- (id)copyWithZone:(NSZone *)zone
{
ElementDATE *element = [super copyWithZone:zone];
[element setValue:value];
return element;
}
- (void)readDataFrom:(TemplateStream *)stream
{
[stream readAmount:sizeof(value) toBuffer:&value];
}
- (unsigned int)sizeOnDisk
{
return sizeof(value);
}
- (void)writeDataTo:(TemplateStream *)stream
{
[stream writeAmount:sizeof(value) fromBuffer:&value];
}
- (UInt32)value
{
return value;
}
- (void)setValue:(UInt32)v
{
value = v;
}
- (NSString *)stringValue
{
CFAbsoluteTime cfTime;
OSStatus error = UCConvertSecondsToCFAbsoluteTime(value, &cfTime);
if(error) return nil;
// return [[NSCalendarDate dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)cfTime] descriptionWithLocale:[NSLocale currentLocale]];
return [[NSCalendarDate dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)cfTime] descriptionWithLocale:[NSDictionary dictionaryWithObject:[[NSUserDefaults standardUserDefaults] objectForKey:NSShortTimeDateFormatString] forKey:@"NSTimeDateFormatString"]];
// return [[NSCalendarDate dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)cfTime] descriptionWithLocale:[NSDictionary dictionaryWithObjectsAndKeys:
// [[NSUserDefaults standardUserDefaults] objectForKey:NSShortTimeDateFormatString], @"NSTimeDateFormatString",
// [[NSUserDefaults standardUserDefaults] objectForKey:NSAMPMDesignation], @"NSAMPMDesignation",
// [[NSUserDefaults standardUserDefaults] objectForKey:NSMonthNameArray], @"NSMonthNameArray",
// [[NSUserDefaults standardUserDefaults] objectForKey:NSShortMonthNameArray], @"NSShortMonthNameArray",
// [[NSUserDefaults standardUserDefaults] objectForKey:NSWeekDayNameArray], @"NSWeekDayNameArray",
// [[NSUserDefaults standardUserDefaults] objectForKey:NSShortWeekDayNameArray], @"NSShortWeekDayNameArray",
// nil]];
// return [[NSCalendarDate dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)cfTime] descriptionWithLocale:[NSDictionary dictionaryWithObject:[[NSCalendar currentCalendar] calendarIdentifier] forKey:@"NSLocaleCalendar"]];
// return [[NSCalendarDate dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)cfTime] descriptionWithCalendarFormat:[NSCalendar currentCalendar]];// timeZone:[NSTimeZone localTimeZone] locale:[NSDictionary dictionaryWithObject:[NSCalendar currentCalendar] forKey:@"NSLocaleCalendar"]];
}
- (void)setStringValue:(NSString *)str
{
// UCConvertCFAbsoluteTimeToSeconds((CFAbsoluteTime)[[NSCalendarDate dateWithString:str] timeIntervalSinceReferenceDate], &value);
UCConvertCFAbsoluteTimeToSeconds((CFAbsoluteTime)[[NSCalendarDate dateWithNaturalLanguageString:str] timeIntervalSinceReferenceDate], &value);
// UCConvertCFAbsoluteTimeToSeconds((CFAbsoluteTime)[[NSCalendarDate dateWithNaturalLanguageString:str locale:[NSDictionary dictionaryWithObject:[NSLocale currentLocale] forKey:@"NSLocale"]] timeIntervalSinceReferenceDate], &value);
}
@end