bugGNUstep - Bugs: bug #8884, NSCalendarDate...

Group
 
 

bug #8884: NSCalendarDate +dateWithString:calendarFormat: problem

Submitter:  None
Submitted:  Tue 11 May 2004 08:44:38 PM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  CaS
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 13 Nov 2006 12:36:25 PM UTC, comment #3: 


Could you please open this bug again, it's still not working as it should.

Here's proof (I used io from the Etoile repository for this, but it uses the GNUstep frameworks.)

------- PROOF START --------
Io> date := NSCalendarDate alloc

==>  Io2Objc_0x9025b80:

Io> date := date initWithString:calendarFormat:("2006-08-03T12:50:24+02:00", "%Y-%m-%d")

==>  Io2Objc_0x9025b80:

Io> date description

==> 2006-08-03    // problem: only first part was parsed, unmatching pattern not detected!

Io> date := NSCalendarDate dateWithString:calendarFormat:("2006-08-03 +0100", "%Y-%m-%d %Z") description
2006-11-12 00:47:07.916 ioobjc[1320] Unknown time zone name ‘+’.

==> 2006-08-03 GMT+0000   // problem: time zone not recognized, but issue ignored

Io> date := NSCalendarDate dateWithString:calendarFormat:("", "%Y-%m-%d") description
2006-11-12 00:53:33.876 ioobjc[1320] File NSCalendarDate.m: 1356. In [NSCalendarDate -initWithYear:month:day:hour:minute:second:timeZone:] invalid month given - 0
2006-11-12 00:53:33.876 ioobjc[1320] File NSCalendarDate.m: 1361. In [NSCalendarDate -initWithYear:month:day:hour:minute:second:timeZone:] invalid day given - 0

==> 0000-01-00  // problem: not only did it parse wrong, it also set the day to 0,
                // which is guaranteed not to happen in the documentation to the method.

------- PROOF END -------

Another issue is that there are some (potentially broken) time zone names like "+0000"
(Real life example: "<lastBuildDate>Fri, 10 Nov 2006 16:28:30 +0000</lastBuildDate>", found
in http://www.symlink.ch/symlinkch.rss. How can I parse that with that method?

Günther Noack <guenthernoack>
Thu 13 May 2004 09:43:00 AM UTC, comment #2: 

Fixed in CVS.  Also made the following changes/fixes -
Logging of errors only done when compiled for debug.
More error logging.
Accept nil/empty format and description strings.
Default year to be current year as MacOS-X does.
Document default values for year. month. day etc.
Some performace optimisations.

Richard Frith-Macdonald <CaS>
Group Member
Thu 13 May 2004 08:13:54 AM UTC, comment #1: 

I agree ... this method should return nil on any inconsistency between the format and the supplied string.
Will look into fixing it.

Richard Frith-Macdonald <CaS>
Group Member
Tue 11 May 2004 08:44:38 PM UTC, original submission:  

This method should return nil in the case of bad input - instead it returns an undefined, but invalid, date.  This makes catching bad input rather tricky.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follow 5 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-11-13 guenthernoack Carbon-Copy- Added -email is unavailable-
2004-05-13 CaS StatusNone Fixed
    Open/ClosedAnalyzed Closed
2004-05-13 CaS Assigned toNone CaS
    Open/ClosedOpen Analyzed

Back to the top

Powered by Savane 3.13-4448.
Corresponding source code