/Tableture/Classes/Utilities/KLCalendar/KLDate.h

https://bitbucket.org/tableture/jtnews-code · C Header · 87 lines · 20 code · 23 blank · 44 comment · 0 complexity · 836922ac815492dc3c37c29f393a9ddd MD5 · raw file

  1. /*
  2. * Copyright (c) 2008, Keith Lazuka, dba The Polypeptides
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * - Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * - Neither the name of the The Polypeptides nor the
  10. * names of its contributors may be used to endorse or promote products
  11. * derived from this software without specific prior written permission.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY Keith Lazuka ''AS IS'' AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. * DISCLAIMED. IN NO EVENT SHALL Keith Lazuka BE LIABLE FOR ANY
  17. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. //
  25. // NOTES
  26. //
  27. // (1) KLDate was created because I didn't want to mess around with time,
  28. // just dates. Also, some of the CFCalendar* functions are quite
  29. // slow on the iPhone (or at least they were in iPhone OS 2.0
  30. // when I created this class).
  31. //
  32. // (2) Special effort was made such that changing the iPhone's
  33. // regional format and timezone would not change the logical date.
  34. // This was needed in my application, Goalkeep, because the purpose
  35. // of the app was to chain together several days in a row. If you
  36. // changed the timezone or the regional format, I didn't want the
  37. // chain to break just because of international time issues.
  38. //
  39. // (3) Considering the above notes, it may be prudent
  40. // to replace KLDate with NSDate.
  41. //
  42. @interface KLDate : NSObject <NSCopying, NSCoding> {
  43. NSInteger _year, _month, _day;
  44. }
  45. -(NSString*)klDateToNSString;
  46. -(NSString*)klDateToNSStringSecond;
  47. + (id)today;
  48. // Designated initializer
  49. - (id)initWithYear:(NSInteger)year month:(NSUInteger)month day:(NSUInteger)day;
  50. - (NSComparisonResult)compare:(KLDate *)otherDate;
  51. - (NSInteger)yearOfCommonEra;
  52. - (NSInteger)monthOfYear;
  53. - (NSInteger)dayOfMonth;
  54. - (BOOL)isEqualThan:(KLDate *)aDate;
  55. - (BOOL)isEarlierThan:(KLDate *)aDate;
  56. - (BOOL)isLaterThan:(KLDate *)aDate;
  57. - (BOOL)isToday;
  58. - (BOOL)isTheDayBefore:(KLDate *)anotherDate;
  59. // NSCopying
  60. - (id)copyWithZone:(NSZone *)zone;
  61. // NSCoding
  62. - (id)initWithCoder:(NSCoder *)decoder;
  63. - (void)encodeWithCoder:(NSCoder *)encoder;
  64. @end