Developer Area

root/apps/iphone/superbook/trunk/Classes/NSDate+ISO8601Parsing.h @ 902

Revision 885, 2.1 kB (checked in by henri, 3 years ago)

Added (unfinished) TelPages? support. Refactored some main view controller code.

Line 
1/*NSDate+ISO8601Parsing.h
2 *
3 *Created by Peter Hosey on 2006-02-20.
4 *Copyright 2006 Peter Hosey. All rights reserved.
5 *Modified by Matthew Faupel on 2009-05-06 to use NSDate instead of NSCalendarDate (for iPhone compatibility).
6 *Modifications copyright 2009 Micropraxis Ltd.
7 */
8
9#import <Foundation/Foundation.h>
10
11/*This addition parses ISO 8601 dates. A good introduction: <http://www.cl.cam.ac.uk/~mgk25/iso-time.html>
12 *
13 *Parsing can be done strictly, or not. When you parse loosely, leading whitespace is ignored, as is anything after the date.
14 *The loose parser will return an NSDate for this string: @" \t\r\n\f\t  2006-03-02!!!"
15 *Leading non-whitespace will not be ignored; the string will be rejected, and nil returned. See the README that came with this addition.
16 *
17 *The strict parser will only accept a string if the date is the entire string. The above string would be rejected immediately, solely on these grounds.
18 *Also, the loose parser provides some extensions that the strict parser doesn't.
19 *For example, the standard says for "-DDD" (an ordinal date in the implied year) that the logical representation (meaning, hierarchically) would be "--DDD", but because that extra hyphen is "superfluous", it was omitted.
20 *The loose parser will accept the extra hyphen; the strict parser will not.
21 *A full list of these extensions is in the README file.
22 */
23
24//The default separator for time values. Currently, this is ':'.
25extern unichar ISO8601ParserDefaultTimeSeparatorCharacter;
26
27@interface NSDate(ISO8601Parsing)
28
29//This method is the one that does all the work. All the others are convenience methods.
30+ (NSDate *)dateWithISO8601String:(NSString *)str strictly:(BOOL)strict getRange:(out NSRange *)outRange;
31+ (NSDate *)dateWithISO8601String:(NSString *)str strictly:(BOOL)strict;
32
33//Strictly: NO.
34+ (NSDate *)dateWithISO8601String:(NSString *)str timeSeparator:(unichar)timeSep getRange:(out NSRange *)outRange;
35+ (NSDate *)dateWithISO8601String:(NSString *)str timeSeparator:(unichar)timeSep;
36+ (NSDate *)dateWithISO8601String:(NSString *)str getRange:(out NSRange *)outRange;
37+ (NSDate *)dateWithISO8601String:(NSString *)str;
38
39@end
Note: See TracBrowser for help on using the browser.
Telnic
Search This Site
Partners
Neustar
ICANN
Main site | WHOIS | Sell .tel | FAQ | Archived Site | About Telnic | Contact Us