Cocoa library used to parse and generate date strings encoded using Microsoft JSON formats.
There are three general formats supported,
-
DateTime without offset data
"/Date(1198908717056)/"
-
DateTime with offset data
"/Date(1198908717056+0500)/"
-
DateTimeOffset
{ DateTime: "/Date(1198908717056)/", OffsetMinutes: "-360" }
Operations can take place using either the MSJSONDate class methods, or the MSJSONDate category for NSDate instances.
Example snippet:
id json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
id dateElement = json[@"DateLastModified"];
NSDate *date = [MSJSONDate dateWithJSON:dateElement];
Example snippet:
NSDate *date = [NSDate date];
NSMutableDictionary *jsonElement = [NSMutableDictionary new];
[jsonElement setObject:[date jsonValue] forKey:@"DateLastModified"];
- Download MSJSONDate
- Unzip and import the MSJSONDate subdirectory into your Xcode project.
- Simply
#import "MSJSONDate.h"
in your implementation files to get started.
MSJSONDate was created by Cory Metcalfe (coryallegory), and is available under the MIT license. See the LICENSE file for more info.