Hi Louis, can you wrap that up into a pull request patching ERXTimestampUtilities instead of ERXTimestampUtility (which has been deprecated)? If you already wrote some testing code you could add that to ERXTest too :-)
Am 10.12.2012 um 22:20 schrieb Louis Demers <[email protected]>: > Hi, > > I tried using ERXTimestampUtility.firstDateInNextMonth() and > ERXTimestampUtility.firstDateInSameMonth() and didn't get what I expected. > Either it's a bug or, the name is less than ideal. I started testing other > calls in like firstDateInSameWeek() and discovered problems as well. > > If anybody is using those calls, please explain what they are supposed to do > ... > > > Here are some test I ran on the 2012-11-20 22:33:13 Etc/GMT > > <snip> > > So here are what I would propose > > // First we should correct the offset by one (making month 1 based instead of > 0 base) I agree that this would make more sense though that would certainly break peoples code and if I see it correct it mimics the return values of GregorianCalendar which is 0-based. Perhaps some Javadocs specifying that bit of info would be better? jw > > public static int monthOfYear(NSTimestamp t) { > return 1 + calendarForTimestamp(t).get(Calendar.MONTH); > } > > Then correct the faulty methods > > public NSTimestamp firstDateInSameWeek(NSTimestamp value) { > return new NSTimestamp( > ERXTimestampUtility.yearOfCommonEra(value), > ERXTimestampUtility.monthOfYear(value) , > ERXTimestampUtility.dayOfMonth(value) - > ERXTimestampUtility.dayOfWeek(value) + 1, > 0, 0, 0, NSTimeZone.defaultTimeZone() > ); > } > > public NSTimestamp firstDateInSameMonth(NSTimestamp value) { > return new NSTimestamp(ERXTimestampUtility.yearOfCommonEra(value), > ERXTimestampUtility.monthOfYear(value), 1, 0, 0, 0, > NSTimeZone.defaultTimeZone()); > } > > > > Cheers > > > Louis Demers eng. > Vice-President, Co-Founder > Obzerv Technologies Inc. > 400 Jean Lesage, suite 201 > Quebec, QC, Canada > G1K 8W1 > T 418.524.3522 > F 418.524.6745 > www.obzerv.com > > > > > > > Louis Demers eng. > www.obzerv.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
