bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #61035] NSDateFormatter truncates rather than rounding


From: Larry Campbell
Subject: [bug #61035] NSDateFormatter truncates rather than rounding
Date: Thu, 12 Aug 2021 18:45:14 -0400 (EDT)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15

URL:
  <https://savannah.gnu.org/bugs/?61035>

                 Summary: NSDateFormatter truncates rather than rounding
                 Project: GNUstep
            Submitted by: lcampbel
            Submitted on: 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
         Discussion Lock: Any

    _______________________________________________________

Details:

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).




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61035>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]