Artikel getaggt mit SenTestingKit

NSDateFormatter case sensitive trap

Though NSDateFormatter behaves slightly different than documented, the following might even be correct, as strange as it might look (mind the last two lines):

-(void)testNSDateFormatterTrap
{
    NSDateFormatter *lower = [[[NSDateFormatter alloc] init] autorelease];
    lower.dateFormat = @"yyyy-MM-dd HH:mm:SS ZZZ";
 
    NSDateFormatter *upper = [[[NSDateFormatter alloc] init] autorelease];
    upper.dateFormat = @"YYYY-MM-dd HH:mm:SS ZZZ";
 
    lower.timeZone = upper.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
 
    NSDate *d = [lower dateFromString:@"1970-01-01 00:00:00 +0000"];
    STAssertEqualObjects(@"1970-01-01 00:00:00 +0000", [lower stringFromDate:d], @"lower iso wrong");
    STAssertEqualObjects(@"1970-01-01 00:00:00 +0000", [upper stringFromDate:d], @"upper iso wrong");
 
    d = [d addTimeInterval:(-60*60)];
 
    STAssertEqualObjects(@"1969-12-31 23:00:00 +0000", [lower stringFromDate:d], @"lower iso wrong");
    STAssertEqualObjects(@"1970-12-31 23:00:00 +0000", [upper stringFromDate:d], @"upper iso wrong");
}

The Unicode Format Pattern Documentation explains the difference of the upper- and lowercase year format – but frankly I don’t get the “Year of week of year” idea.

But that subtracting one hour in fact adds almost a whole year – that’s odd to me.

So I rather stay away from the uppercase form – be it correct or buggy.

Seen with iPhone SDK 3.1.2 and XCode 3.2.1 on Snow Leopard.

Update:

I think I got it! Uppercase YYYY makes sense only in combination with a calendar week – and not months or quarters.

Look at January 1st 2010. It belongs to calendar week 53 of 2009. Week 1/2010 starts on Jan 4th.

Tags: , , , , , ,

Upgrade to Snow Leopard

  1. Mac OS X 10.6 Snow Leopard (partition 25G, HFS+ Journaled, Upper/Lower)
  2. Mac OS X 10.5 Leopard (partition 25G, HFS+ Journaled, Upper/Lower)
  3. partition userspace 100G, HFS+ Journaled, Upper/Lower
    $ cat /etc/fstab
    # mount partition "userspace" as /Users
    UUID=D016E3FD-E322-3006-A8F5-D2348C6A5B7B	/Users	hfs	rw,auto
  4. create user “mig”
  5. TimeMachine restore Users + Settings
  6. delete user “mig”
  7. manually copy user “Shared”
  8. iPhone SDK 3.1.2 + XCode 3.2.1
  9. modgenerator 1.5 plus trick
    $ ln -s /Developer/usr/bin/momc /Developer/Library/Xcode/Plug-ins/XDCoreDataModel.xdplugin/Contents/Resources/momc
  10. git 1.6.5.2, manually add to .bash_profile:
    export PATH=$PATH:/usr/local/git/bin
  11. Macports / http://trac.macports.org/wiki/Migration
    $ sudo port selfupdate
    $ sudo port install bcpp pwgen wget lftp fortune optipng graphviz ragel imagemagick
    $ sudo port clean --all installed
    $ sudo port -f uninstall inactive
  12. graphviz-2.25.20091129.0545.pkg
  13. Textwrangler 3.0 (2538)
  14. Gimp 2.6.7
  15. NeoOffice 3.0.1
  16. Evernote 1.5.2 (62233)
  17. TrueCrypt 6.3a
  18. Dropbox v0.6.570
  19. Skype 2.8.0.722
  20. Firefox 3.5,5
  21. Miro Video Player 2.5.3 (775f9134)
  22. wxMaxima-0.8.3 & Maxima-5.19.2.dmg
  23. Twain SANE Scanner Support

Remaining issues:

  1. SenTestingKit error highlighting not working.

Tags: , , , , , , , , ,

NSDateFormatter & Http Header

Ever tried to get e.g. the “Last-Modified” HTTP response header field into a NSDate object? That’s no real fun, because

  1. this standard formatting isn’t digested by default,
  2. the required format string doesn’t quite work as documented.

Den Rest des Eintrags lesen. »

Tags: , , , , , , ,

Unit Testing / iPhone

Having Eclipse & JUnit in mind I missed unit testing quite a bit while developing with XCode for iPhone.

As a first shot, I set SenTestingKit up as explained by it’s author and it works really nicely. One thing I still miss is Step’n'Trace debugging the tests.

Other intros to the topic from Apple about OCUnit (2005) and SenTestingKit (2008) are ok but not as good as from the author of SenTestingKit.

Didn’t examine other Unit Test frameworks like e.g. the one from Google yet.

Tags: , , , , ,