<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Relative date to now</title>
	<atom:link href="http://blog.coriolis.ch/2009/02/20/relative-date-to-now/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.coriolis.ch/2009/02/20/relative-date-to-now/</link>
	<description>Just another Coriolis weblog</description>
	<lastBuildDate>Sat, 06 Aug 2011 21:59:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Stephan</title>
		<link>http://blog.coriolis.ch/2009/02/20/relative-date-to-now/comment-page-1/#comment-1097</link>
		<dc:creator>Stephan</dc:creator>
		<pubDate>Tue, 07 Apr 2009 10:06:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coriolis.ch/?p=128#comment-1097</guid>
		<description>Even if the daylight savings changes, substracting or adding 86400 seconds to your date will always give you the correct day. No worries.</description>
		<content:encoded><![CDATA[<p>Even if the daylight savings changes, substracting or adding 86400 seconds to your date will always give you the correct day. No worries.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eduardito</title>
		<link>http://blog.coriolis.ch/2009/02/20/relative-date-to-now/comment-page-1/#comment-1062</link>
		<dc:creator>eduardito</dc:creator>
		<pubDate>Mon, 06 Apr 2009 06:15:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coriolis.ch/?p=128#comment-1062</guid>
		<description>Hi Stephan

That is what i&#039;m trying to do, the problem is that I do not know how to get the &quot;right date&quot;. For example, I could get the day and all but I don&#039;t know how to deal with daylight savings and timezones and all that. I&#039;m lost man</description>
		<content:encoded><![CDATA[<p>Hi Stephan</p>
<p>That is what i&#8217;m trying to do, the problem is that I do not know how to get the &#8220;right date&#8221;. For example, I could get the day and all but I don&#8217;t know how to deal with daylight savings and timezones and all that. I&#8217;m lost man</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephan</title>
		<link>http://blog.coriolis.ch/2009/02/20/relative-date-to-now/comment-page-1/#comment-1045</link>
		<dc:creator>Stephan</dc:creator>
		<pubDate>Sun, 05 Apr 2009 16:43:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coriolis.ch/?p=128#comment-1045</guid>
		<description>Just add or substract 86400 (number of seconds in a day) to your date and it should do what you&#039;re looking for.</description>
		<content:encoded><![CDATA[<p>Just add or substract 86400 (number of seconds in a day) to your date and it should do what you&#8217;re looking for.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eduardito</title>
		<link>http://blog.coriolis.ch/2009/02/20/relative-date-to-now/comment-page-1/#comment-1015</link>
		<dc:creator>eduardito</dc:creator>
		<pubDate>Sat, 04 Apr 2009 14:03:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coriolis.ch/?p=128#comment-1015</guid>
		<description>Thanks a lot! I&#039;m still facing a lot of problems. Can you help me out a bit?

Basically I&#039;m trying to get the date and be able to get to the next day or previous day.. but I just can&#039;t figure out! ( with the assumption of taking into consideration the handling of time zones and all different calendars around the world.

Do you have any suggestions and all? I would even donate for the help!</description>
		<content:encoded><![CDATA[<p>Thanks a lot! I&#8217;m still facing a lot of problems. Can you help me out a bit?</p>
<p>Basically I&#8217;m trying to get the date and be able to get to the next day or previous day.. but I just can&#8217;t figure out! ( with the assumption of taking into consideration the handling of time zones and all different calendars around the world.</p>
<p>Do you have any suggestions and all? I would even donate for the help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Billy Gray</title>
		<link>http://blog.coriolis.ch/2009/02/20/relative-date-to-now/comment-page-1/#comment-834</link>
		<dc:creator>Billy Gray</dc:creator>
		<pubDate>Thu, 26 Mar 2009 13:46:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coriolis.ch/?p=128#comment-834</guid>
		<description>Hi Stephan,

Nice catch, and thanks for letting me know about the daysAgo issue.

I really enjoyed your comment above, &quot;Simple task, I thought. Until I looked at the documentation...&quot;, I experienced the same thing when putting together my own code.  When I look around at examples it just seems like there aren&#039;t too many snappy ways of doing this. Also, I&#039;m spoiled by ActiveSupport in Rails, so that&#039;s why I started the NSDate (Helper) project, figure at least group up some of these calculations.

http://github.com/billymeltdown/nsdate-helper

I should have the daysAgo fix in there soon!

Cheers,
Billy</description>
		<content:encoded><![CDATA[<p>Hi Stephan,</p>
<p>Nice catch, and thanks for letting me know about the daysAgo issue.</p>
<p>I really enjoyed your comment above, &#8220;Simple task, I thought. Until I looked at the documentation&#8230;&#8221;, I experienced the same thing when putting together my own code.  When I look around at examples it just seems like there aren&#8217;t too many snappy ways of doing this. Also, I&#8217;m spoiled by ActiveSupport in Rails, so that&#8217;s why I started the NSDate (Helper) project, figure at least group up some of these calculations.</p>
<p><a  href="http://github.com/billymeltdown/nsdate-helper" rel="nofollow">http://github.com/billymeltdown/nsdate-helper</a></p>
<p>I should have the daysAgo fix in there soon!</p>
<p>Cheers,<br />
Billy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephan</title>
		<link>http://blog.coriolis.ch/2009/02/20/relative-date-to-now/comment-page-1/#comment-437</link>
		<dc:creator>Stephan</dc:creator>
		<pubDate>Fri, 20 Feb 2009 11:33:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coriolis.ch/?p=128#comment-437</guid>
		<description>If there are less than 24h between the two dates, doesnt work:

If [NSDate date] = 2009-02-20 12:26:00:

NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4];
[formatter setDateFormat:@&quot;yyyy-MM-dd HH:mm:ss&quot;]; /* Unicode Locale Data Markup Language */
NSDate *date1 = [formatter dateFromString:@&quot;2009-02-20 12:10:00&quot;];
NSDate *date2 = [formatter dateFromString:@&quot;2009-02-19 14:10:00&quot;];
NSDate *date3 = [formatter dateFromString:@&quot;2009-02-18 23:59:00&quot;];
NSDate *date4 = [formatter dateFromString:@&quot;2009-02-18 11:30:00&quot;];
	
NSLog(@&quot;diff1: %d&quot;, (int)([date1 timeIntervalSinceNow] / (60*60*24)));
NSLog(@&quot;diff2: %d&quot;, (int)([date2 timeIntervalSinceNow] / (60*60*24)));
NSLog(@&quot;diff3: %d&quot;, (int)([date3 timeIntervalSinceNow] / (60*60*24)));
NSLog(@&quot;diff4: %d&quot;, (int)([date4 timeIntervalSinceNow] / (60*60*24)));

diff1: 0 correct: today
diff2: 0 incorrect: yesterday
diff3: -1 incorrect: two days ago
diff4: -2 correct: two days ago</description>
		<content:encoded><![CDATA[<p>If there are less than 24h between the two dates, doesnt work:</p>
<p>If [NSDate date] = 2009-02-20 12:26:00:</p>
<p>NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];<br />
[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4];<br />
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; /* Unicode Locale Data Markup Language */<br />
NSDate *date1 = [formatter dateFromString:@"2009-02-20 12:10:00"];<br />
NSDate *date2 = [formatter dateFromString:@"2009-02-19 14:10:00"];<br />
NSDate *date3 = [formatter dateFromString:@"2009-02-18 23:59:00"];<br />
NSDate *date4 = [formatter dateFromString:@"2009-02-18 11:30:00"];</p>
<p>NSLog(@&#8221;diff1: %d&#8221;, (int)([date1 timeIntervalSinceNow] / (60*60*24)));<br />
NSLog(@&#8221;diff2: %d&#8221;, (int)([date2 timeIntervalSinceNow] / (60*60*24)));<br />
NSLog(@&#8221;diff3: %d&#8221;, (int)([date3 timeIntervalSinceNow] / (60*60*24)));<br />
NSLog(@&#8221;diff4: %d&#8221;, (int)([date4 timeIntervalSinceNow] / (60*60*24)));</p>
<p>diff1: 0 correct: today<br />
diff2: 0 incorrect: yesterday<br />
diff3: -1 incorrect: two days ago<br />
diff4: -2 correct: two days ago</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nst</title>
		<link>http://blog.coriolis.ch/2009/02/20/relative-date-to-now/comment-page-1/#comment-436</link>
		<dc:creator>nst</dc:creator>
		<pubDate>Fri, 20 Feb 2009 11:31:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coriolis.ch/?p=128#comment-436</guid>
		<description>Sorry:

NSUInteger dayDiff = (int)[date timeIntervalSinceNow] / (60*60*24) * -1;</description>
		<content:encoded><![CDATA[<p>Sorry:</p>
<p>NSUInteger dayDiff = (int)[date timeIntervalSinceNow] / (60*60*24) * -1;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nst</title>
		<link>http://blog.coriolis.ch/2009/02/20/relative-date-to-now/comment-page-1/#comment-435</link>
		<dc:creator>nst</dc:creator>
		<pubDate>Fri, 20 Feb 2009 11:15:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.coriolis.ch/?p=128#comment-435</guid>
		<description>NSUInteger dayDiff = [date timeIntervalSinceNow] / (60*60*24);</description>
		<content:encoded><![CDATA[<p>NSUInteger dayDiff = [date timeIntervalSinceNow] / (60*60*24);</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: www.coriolis.ch @ 2012-02-05 00:11:54 -->
