Taking the Metro: WordPress.com for Windows 8

Today Microsoft unveiled the Windows 8 Consumer Preview at Mobile World Congress and demoed our new WordPress.com app during their presentation. I was able to be a part of a great team at Automattic (including MT and Stephane) that built the app.

The app creates a beautiful reading experience for browsing the WordPress.com Freshly Pressed posts and the ability to like and reblog the post you are reading. It also includes some great social features that makes it easy to share content from other Windows 8 apps to your blog effortlessly.

The app is free and is already available in the Windows Store, so download the Consumer Preview and check it out! The app is also open source so have a look at http://win8.svn.automattic.com if you’re curious about developing for Windows 8.

How to Get an NSDate for a Specific Day of Week and Time from an Existing NSDate

Worst Post Title ever! This one took me a bit to figure out so I thought I’d post it in case anyone else out there had troubles. I wanted to get an NSDate for a specific day of the week and time from an existing NSDate object in order to create a countdown timer.

This example will get you the NSDate for the following Monday at 8am:

NSDate *today = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[gregorian setLocale:[NSLocale currentLocale]];

NSDateComponents *nowComponents = [gregorian components:NSYearCalendarUnit | NSWeekCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:today];

[nowComponents setWeekday:2]; //Monday
[nowComponents setWeek: [nowComponents week] + 1]; //Next week
[nowComponents setHour:8]; //8a.m.
[nowComponents setMinute:0];
[nowComponents setSecond:0];

NSDate *beginningOfWeek = [gregorian dateFromComponents:nowComponents];

Now that you have the new NSDate, you can calculate the difference between the two by using fromDate.