Questions tagged [nsdatecomponents]

NSDateComponents is a class in Apple's Cocoa and CocoaTouch frameworks which represents either a date or a period of time as composed of several elements -- days, hours, and months, for example.

NSDateComponents encapsulates the components of a date in an extendable, object-oriented manner.

Resources:

567 questions
-1
votes
1 answer

Compare NSDateComponents to integer (or convert NSDateComponents to integer)

I'm trying to check if X days passed from the app installation to unlock some features NSDate *now = [NSDate date]; NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; NSDateComponents…
fabdurso
  • 2,366
  • 5
  • 29
  • 55
-1
votes
1 answer

Extract Date and Hour from NSDate - Objective C

I have dateString with this format "mm/dd/yyyy '-' HH:mm". I want to extract the date in string and hour in string. I've tried the following code but this return a wrong date: - (void) extractDate: (NSString *)dateString intoHour: (NSString…
Haroun SMIDA
  • 1,106
  • 3
  • 16
  • 32
-1
votes
1 answer

Compare two dates for Countdown Timer Swift2

I'm querying the createdAt column from Parse. My Parse methods are above this code and then I'm doing this: var createdAt = object.createdAt if createdAt != nil { let twentyFourHours = NSTimeInterval(60 * 60 * 24) self.expiresAt =…
Lukesivi
  • 2,206
  • 4
  • 25
  • 43
-1
votes
1 answer

How to crawl entire wikimapia?

i need a sitemap which can help to people and google to know pages as well. I've tried WebSphinx application. I realize if I put wikipedia.org as the starting URL, it will not crawl further. Hence, how to actually crawl the entire Wikipedia? Can…
raminmm
  • 1
  • 1
-1
votes
1 answer

dateFromComponents returning wrong value

I'm trying to set the month and year of [NSDate date] but the function dateFromComponents return the wrong value, this is my code: NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSCalendarIdentifierGregorian]; //…
Erik
  • 2,500
  • 6
  • 28
  • 49
-1
votes
1 answer

Format NSDate with different calendar identifier?

I'm trying to print a human-friendly date that's of a different calendar identifier. I am able to get the date, but when I format it, it outputs back to Gregorian (or the user's current calendar I think). Here's what I'm trying: var calendar =…
TruMan1
  • 33,665
  • 59
  • 184
  • 335
-1
votes
1 answer

Confusion over NSDateComponents

I have this method that deletes all the objects in the dictionary if a new day has begun: -(void)flushDictionaryIfNeeded{ NSLog(@"Flush called"); if([self.messagedTodayDict count]>0) { //get any date NSDate *aDate = nil; …
Kex
  • 8,023
  • 9
  • 56
  • 129
-1
votes
1 answer

how to extract date components from sum of year month day weekday multiply by certain integer in iOS?

The apple sample project DateSectionTitles demonstrates how to group sections by year and month, how to extends it to support year month day and weekday? sectionIdentifier is a transient attribute derives from persistent date attribute timestamp. -…
Andy_24
  • 1,353
  • 2
  • 12
  • 20
-1
votes
1 answer

Change NSDate to Friday of that Week

Currently I have the below code to increment my days to the next friday, however what I need is to get the friday of the current week. For example if it is last Sunday, 03/01. I would expect my response to be last Friday(02/28) not Friday(03/06). …
bmjohns
  • 6,344
  • 1
  • 33
  • 39
-1
votes
2 answers

Creating NSDate from components without "timezone correction"

I have a function func createDate(day: Int, month: Int, year: Int) -> NSDate { var comp = NSDateComponents() comp.day = day comp.month = month comp.year = year var cal = NSCalendar.currentCalendar() if var date =…
Christian
  • 1,589
  • 1
  • 18
  • 36
-1
votes
1 answer

How to get a difference year, month, day between two dates in android App

I am developing an android App. I would like to know how to calculate exact number of "years, months and days" between two dates. e.g. 1. "2014.1.3" to "2015.1.4" →Answer: "1 year and 1 day" "2013.1.3" to "2014.4.2" →Answer: "1 year and…
supermonkey
  • 631
  • 11
  • 25
-1
votes
1 answer

How to get a list of NSDates for the next 3 months which match Wednesday?

I am looking to add a reminder feature to my application using UILocalNotification however there is a limit of just 64 registered notifications and with my app I have calculated that users may go beyond that limit. Therefore I am now looking at…
MonkeyBlue
  • 2,234
  • 6
  • 31
  • 41
-1
votes
1 answer

NSDateComponents getting dates between 2 dates has incorrect day property

I am using NSDateComponents and NSCalendar to get the dates between two dates. // Get dates between before and after NSDateComponents *betweenDateComponents = [calendar components:componentFlags …
user3344977
  • 3,584
  • 4
  • 32
  • 88
-1
votes
1 answer

iOS: Date comparison failing under real-world conditions, works under simulated conditions

I'm using this code to compare two dates, to see if the stored date is yesterday essentially: NSDate *date = [wordData objectForKey:@"date"]; NSLog(@"Word data date: %@", [wordData objectForKey:@"date"]); NSDate *nowDate = [NSDate…
Nicholas Smith
  • 11,642
  • 6
  • 37
  • 55
-1
votes
1 answer

Comparing two dates with NSDateComponents

I'm using this code to compare two dates and return the number of difference in days. I want to use it and get the minutes and the Hours, but I get the same number. NSDate *todaysDate =[NSDate date]; NSDate *eventDate = [self.event…
user3241911
  • 481
  • 6
  • 15