-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATDateTimeFieldBody.m
More file actions
67 lines (50 loc) · 1.17 KB
/
ATDateTimeFieldBody.m
File metadata and controls
67 lines (50 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// ATDateTimeFieldBody.m
// ATMail
//
// Created by 高田 明史 on 06/04/08.
// Copyright 2006 __MyCompanyName__. All rights reserved.
//
#import "ATDateTimeFieldBody.h"
#import "ATTokenScanner.h"
@implementation ATDateTimeFieldBody
- (id)initWith:(NSString *)aString
{
ATTokenScanner *aTokenScanner = [ATTokenScanner scannerWith:aString];
NSCalendarDate *aDateTime = nil;
[super init];
if ([aTokenScanner scanDateTimeInto:&aDateTime] && [aTokenScanner isAtEnd])
{
[self setValue:aDateTime];
return self;
}
else
{
[self release];
return nil;
}
}
- (void)dealloc
{
[self setValue:nil];
[super dealloc];
}
- (void)setValue:(NSCalendarDate *)aValue
{
[value release];
value = [aValue copy];
}
- (NSCalendarDate *)value
{
return value;
}
- (NSString *)stringValue
{
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setDateStyle:NSDateFormatterFullStyle];
[dateFormatter setTimeStyle:NSDateFormatterLongStyle ];
NSString *formattedDateString = [dateFormatter stringFromDate:[self value]];
return formattedDateString;
}
@end