This repository was archived by the owner on Jun 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathOneNotePickerSection.m
More file actions
58 lines (48 loc) · 1.87 KB
/
OneNotePickerSection.m
File metadata and controls
58 lines (48 loc) · 1.87 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
//
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//
#import "OneNotePickerSection.h"
#import "OneNotePickerController.h"
@implementation OneNotePickerSection
- (NSDictionary *)resultDictionary
{
NSMutableDictionary *result = [NSMutableDictionary dictionary];
// Two formatters to support milliseconds or no milliseconds
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.S'Z'"];
[formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
NSDateFormatter *formatter2 = [[NSDateFormatter alloc] init];
[formatter2 setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
[formatter2 setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
NSDate *date = [formatter dateFromString:jsonData_[@"createdTime"]];
NSDate *date2 = [formatter2 dateFromString:jsonData_[@"createdTime"]];
if (date || date2) {
result[OneNotePickerControllerCreatedTime] = date ?: date2;
}
date = [formatter dateFromString:jsonData_[@"modifiedTime"]];
date2 = [formatter2 dateFromString:jsonData_[@"modifiedTime"]];
if (date || date2) {
result[OneNotePickerControllerModifiedTime] = date ?: date2;
}
NSURL *pagesUrl = [NSURL URLWithString:jsonData_[@"pagesUrl"]];
if (pagesUrl) {
result[OneNotePickerControllerPagesURL] = pagesUrl;
}
NSDictionary *stringValues = @{
OneNotePickerControllerSectionID: @"id",
OneNotePickerControllerSectionName: @"name",
OneNotePickerControllerLastModifiedBy: @"lastModifiedBy"
};
for (NSString *key in [stringValues allKeys]) {
if (jsonData_[stringValues[key]]) {
result[key] = jsonData_[stringValues[key]];
}
}
return result;
}
- (OneNotePickerNavItemType)type
{
return kOneNotePickerNavItemTypeSection;
}
@end