no message

This commit is contained in:
giuseppenuc committed 2015-12-31 16:06:21 +01:00
1 parent de5bd21a43
commit 568ad5c409
262 files changed
+23226 -78

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2015 Giuseppe Nucifora <me@giuseppenucifora.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+114
View File
@@ -0,0 +1,114 @@
//
// NSDate+NSDate_Util.h
//
// Created by Giuseppe Nucifora on 11/02/14.
// Copyright (c) 2014 Giuseppe Nucifora. All rights reserved.
//
#import <Foundation/Foundation.h>
#define kSunRiseMinutes 5*60
#define kSunSetMinutes 19*60
#define kMoonRiseMinutes 17*60
#define kMoonSetMinutes 7*60
static NSString *kNSDateHelperFormatFullDateWithTime = @"MMM d, yyyy h:mm a";
static NSString *kNSDateHelperFormatFullDate = @"MMM d, yyyy";
static NSString *kNSDateHelperFormatShortDateWithTime = @"MMM d h:mm a";
static NSString *kNSDateHelperFormatShortDate = @"MMM d";
static NSString *kNSDateHelperFormatWeekday = @"EEEE";
static NSString *kNSDateHelperFormatWeekdayWithTime = @"EEEE h:mm a";
static NSString *kNSDateHelperFormatTime = @"h:mm a";
static NSString *kNSDateHelperFormatTimeWithPrefix = @"'at' h:mm a";
static NSString *kNSDateHelperFormatSQLDate = @"yyyy-MM-dd";
static NSString *kNSDateHelperFormatSQLTime = @"HH:mm:ss";
static NSString *kNSDateHelperFormatSQLDateWithTime = @"yyyy-MM-dd HH:mm:ss";
static NSString *kNSDateHelperFormatSQLDate_shashSeparated = @"yyyy/MM/dd";
static NSString *kNSDateHelperFormatSQLDate_notSlashSeparated = @"yyyy-MM-dd";
static NSString *kNSDateHelperFormatSQLDateWithTime_shashSeparated = @"yyyy/MM/dd HH:mm:ss";
static NSString *kNSDateHelperFormatSQLDateIT = @"dd-MM-yyyy";
static NSString *kNSDateHelperFormatSQLDateEN = @"MM-dd-yyyy";
static NSString *kNSDateHelperFormatSQLDateIT_shashSeparated = @"dd/MM/yyyy";
static NSString *kNSDateHelperFormatSQLDateEN_shashSeparated = @"MM/dd/yyyy";
@interface NSDate (NSDate_Util)
+ (void)initializeStatics;
+ (NSCalendar *) sharedCalendar;
+ (NSDateFormatter *) sharedDateFormatter;
- (NSDate *) dateToNearestMinutes:(NSInteger)minutes;
- (NSDate *) dateByAddingMinutes:(NSInteger) dMinutes;
- (NSDate *) dateByAddingHours:(NSInteger) hours;
- (NSDate*) dateByAddingDays:(NSInteger) days;
- (NSDate*) dateByAddingYears:(NSInteger) years;
- (NSDate *) dateBySubtractingMinutes:(NSInteger) dMinutes;
- (NSDate *) dateBySubtractingHours:(NSInteger) hours;
- (NSDate *) dateBySubtractingDays:(NSInteger) days;
- (NSDate *) dateBySubtractingYears:(NSInteger) years;
- (NSDate *) dateAtStartOfDay;
- (NSInteger) minutesAfterDate:(NSDate *) aDate;
- (CGFloat) distanceInWeeksToDate:(NSDate *) anotherDate;
- (CGFloat) distanceInDaysToDate:(NSDate *) anotherDate;
- (CGFloat) distanceInHoursToDate:(NSDate *) anotherDate;
- (CGFloat) distanceInMinutesToDate:(NSDate *) anotherDate;
- (CGFloat) distanceInSeconsToDate:(NSDate *) anotherDate;
- (NSDate *) toLocalTime;
- (NSDate *) toGlobalTime;
- (BOOL) isSameYearAsDate:(NSDate *) aDate;
- (BOOL) isEarlierThanDate:(NSDate *) aDate;
- (BOOL) isLaterThanDate:(NSDate *) aDate;
- (NSUInteger) daysAgo;
- (NSUInteger) daysAgoAgainstMidnight;
- (NSString *) stringDaysAgo;
- (NSString *) stringDaysAgoAgainstMidnight:(BOOL)flag;
- (NSUInteger) monthDay;
- (NSUInteger) weekday;
- (NSUInteger) month;
- (NSUInteger) weekNumber;
- (NSUInteger) hour;
- (NSUInteger) minute;
- (NSUInteger) year;
- (long int) utcTimeStamp; //full seconds since
+ (NSDate *) dateFromString:(NSString *) string;
+ (NSDate *) dateFromString:(NSString *) string withFormat:(NSString *) format;
+ (NSDate *) dateFromString:(NSString *) string withFormat:(NSString *) format withTimeZone:(NSTimeZone*) timeZone;
+ (NSString *) stringFromDate:(NSDate *) date withFormat:(NSString *) string;
+ (NSString *) stringFromDate:(NSDate *) date;
+ (NSString *) stringForDisplayFromDate:(NSDate *) date;
+ (NSString *) stringForDisplayFromDate:(NSDate *) date prefixed:(BOOL) prefixed;
+ (NSString *) stringForDisplayFromDate:(NSDate *) date prefixed:(BOOL) prefixed alwaysDisplayTime:(BOOL)displayTime;
- (NSString *) string;
- (NSString *) stringWithFormat:(NSString *) format;
- (NSString *) stringWithFormat:(NSString *) format timeZone:(NSTimeZone*) timezone;
- (NSString *) stringWithDateStyle:(NSDateFormatterStyle) dateStyle timeStyle:(NSDateFormatterStyle) timeStyle;
- (NSDate *) beginningOfWeek;
- (NSDate *) beginningOfDay;
- (NSDate *) endOfWeek;
+ (NSString *) dateFormatString;
+ (NSString *) timeFormatString;
+ (NSString *) timestampFormatString;
+ (NSString *) dbFormatString;
+ (NSString *) parseDateFormatFromString:(NSString *) dateString;
+ (NSString *) WCFStringFromDate:(NSDate*) date;
+ (NSArray*) getSlotTimesFromDate:(NSDate*) date distanceMinutes:(NSInteger) minutes;
- (BOOL)isSameDayAsDate:(NSDate*)otherDate;
+ (NSString *) getUniversalHourFromDateString:(NSString *) string formatterString:(NSString*) formatterString andUppercaseString:(BOOL) uppercaseString;
- (NSString *) getUniversalHourUppercaseString:(BOOL) uppercaseString;
- (NSString *) getNotificationUniversalHourUppercaseString:(BOOL) uppercaseString;
@end
File diff suppressed because it is too large. Load diff
+112
View File
@@ -0,0 +1,112 @@
# NSDate_Utils
[![CI Status](http://img.shields.io/travis/Giuseppe Nucifora/NSDate_Utils.svg?style=flat)](https://travis-ci.org/Giuseppe Nucifora/NSDate_Utils)
[![Version](https://img.shields.io/cocoapods/v/NSDate_Utils.svg?style=flat)](http://cocoapods.org/pods/NSDate_Utils)
[![License](https://img.shields.io/cocoapods/l/NSDate_Utils.svg?style=flat)](http://cocoapods.org/pods/NSDate_Utils)
[![Platform](https://img.shields.io/cocoapods/p/NSDate_Utils.svg?style=flat)](http://cocoapods.org/pods/NSDate_Utils)
## Usage
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
## Installation
NSDate_Utils is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod "NSDate_Utils"
```
```ruby
+ (NSCalendar *) sharedCalendar;
+ (NSDateFormatter *) sharedDateFormatter;
+ (NSString *) dateFormatString;
+ (NSString *) timeFormatString;
+ (NSString *) timestampFormatString;
+ (NSString *) dbFormatString;
+ (NSString *) parseDateFormatFromString:(NSString *) dateString;
+ (NSString *) WCFStringFromDate:(NSDate*) date;
+ (NSArray*) getSlotTimesFromDate:(NSDate*) date distanceMinutes:(NSInteger) minutes;
+ (NSDate *) dateFromString:(NSString *) string;
+ (NSDate *) dateFromString:(NSString *) string withFormat:(NSString *) format;
+ (NSDate *) dateFromString:(NSString *) string withFormat:(NSString *) format withTimeZone:(NSTimeZone*) timeZone;
+ (NSString *) stringFromDate:(NSDate *) date withFormat:(NSString *) string;
+ (NSString *) stringFromDate:(NSDate *) date;
+ (NSString *) stringForDisplayFromDate:(NSDate *) date;
+ (NSString *) stringForDisplayFromDate:(NSDate *) date prefixed:(BOOL) prefixed;
+ (NSString *) stringForDisplayFromDate:(NSDate *) date prefixed:(BOOL) prefixed alwaysDisplayTime:(BOOL)displayTime;
+ (NSString *) getUniversalHourFromDateString:(NSString *) string formatterString:(NSString*) formatterString andUppercaseString:(BOOL) uppercaseString;
- (NSDate *) dateToNearestMinutes:(NSInteger)minutes;
- (NSDate *) dateByAddingMinutes:(NSInteger) dMinutes;
- (NSDate *) dateByAddingHours:(NSInteger) hours;
- (NSDate*) dateByAddingDays:(NSInteger) days;
- (NSDate*) dateByAddingYears:(NSInteger) years;
- (NSDate *) dateBySubtractingMinutes:(NSInteger) dMinutes;
- (NSDate *) dateBySubtractingHours:(NSInteger) hours;
- (NSDate *) dateBySubtractingDays:(NSInteger) days;
- (NSDate *) dateBySubtractingYears:(NSInteger) years;
- (NSDate *) dateAtStartOfDay;
- (NSInteger) minutesAfterDate:(NSDate *) aDate;
- (CGFloat) distanceInWeeksToDate:(NSDate *) anotherDate;
- (CGFloat) distanceInDaysToDate:(NSDate *) anotherDate;
- (CGFloat) distanceInHoursToDate:(NSDate *) anotherDate;
- (CGFloat) distanceInMinutesToDate:(NSDate *) anotherDate;
- (CGFloat) distanceInSeconsToDate:(NSDate *) anotherDate;
- (NSDate *) toLocalTime;
- (NSDate *) toGlobalTime;
- (BOOL) isSameYearAsDate:(NSDate *) aDate;
- (BOOL) isEarlierThanDate:(NSDate *) aDate;
- (BOOL) isLaterThanDate:(NSDate *) aDate;
- (NSUInteger) daysAgo;
- (NSUInteger) daysAgoAgainstMidnight;
- (NSString *) stringDaysAgo;
- (NSString *) stringDaysAgoAgainstMidnight:(BOOL)flag;
- (NSUInteger) monthDay;
- (NSUInteger) weekday;
- (NSUInteger) month;
- (NSUInteger) weekNumber;
- (NSUInteger) hour;
- (NSUInteger) minute;
- (NSUInteger) year;
- (long int) utcTimeStamp; //full seconds since
- (NSString *) string;
- (NSString *) stringWithFormat:(NSString *) format;
- (NSString *) stringWithFormat:(NSString *) format timeZone:(NSTimeZone*) timezone;
- (NSString *) stringWithDateStyle:(NSDateFormatterStyle) dateStyle timeStyle:(NSDateFormatterStyle) timeStyle;
- (NSDate *) beginningOfWeek;
- (NSDate *) beginningOfDay;
- (NSDate *) endOfWeek;
- (BOOL)isSameDayAsDate:(NSDate*)otherDate;
- (NSString *) getUniversalHourUppercaseString:(BOOL) uppercaseString;
- (NSString *) getNotificationUniversalHourUppercaseString:(BOOL) uppercaseString;
```
## Author
Giuseppe Nucifora, me@giuseppenucifora.com
## License
NSDate_Utils is available under the MIT license. See the LICENSE file for more info.