bugGNUstep - Bugs: bug #61035, NSDateFormatter truncates rather...

 
 

bug #61035: NSDateFormatter truncates rather than rounding

Submitter:  Larry Campbell <lcampbel>
Submitted:  Thu 12 Aug 2021 10:45:12 PM UTC
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Fri 10 Dec 2021 12:09:24 AM UTC, comment #1: 

Just tested, this still applies.

Riccardo Mottola <rmottola>
Project Member
Thu 12 Aug 2021 10:45:12 PM UTC, original submission:  

This fails with gnustep but works on Mac OS X:

    NSDateFormatter *df;
    NSTimeInterval t = 650498989.396999955177;
    NSDate *d;
    NSString *s;

    df = [NSDateFormatter new];
    [df setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]];
    [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"];
    [df setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];

    d = [[[NSDate alloc] initWithTimeIntervalSinceReferenceDate:t] autorelease];
    s = [df stringFromDate:d];
    NSAssert([@"2021-08-12T22:09:49.397Z" isEqualToString:s], @"botch: should get 2021-08-12T22:09:49.397Z but got %@", s);

with

2021-08-12 22:40:28.689 gnustep-base-tests[57679:57679] gnustep-base-tests.m:610  Assertion failed in GnustepBaseTests(instance), method nsdate.  botch: should get 2021-08-12T22:09:49.397Z but got 2021-08-12T22:09:49.396Z

because gnustep-base's NSDateFormatter apparently truncates fractional seconds rather than rounding. (This is as of gnustep-base 1.27.0).

Larry Campbell <lcampbel>

 

(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

 

Carbon-Copy List
  • -email is unavailable- added by rmottola (Posted a comment)
  • -email is unavailable- added by lcampbel (Submitted the item)
  •  

    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.

     

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.9