This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Always round down in NSDate's formatter to match NSDate's builtin format
ClosedPublic

Authored by teemperor on Jul 6 2020, 6:08 AM.

Details

Summary

When printing an NSDate (for example with NSLog or po) the seconds value is always rounded down.
LLDB's own formatter however isn't following that behaviour which leads to situations where the
formatted result is sometimes one second off. For example:

(lldb) p [NSDate dateWithTimeIntervalSince1970:0.1]
(__NSTaggedDate *) $1 = [...] 1970-01-01 00:00:01 UTC
(lldb) po [NSDate dateWithTimeIntervalSince1970:0.1]
1970-01-01 00:00:00 +0000

(lldb) p [NSDate dateWithTimeIntervalSince1970:0.6]
(__NSTaggedDate *) $4 =[...] 1970-01-01 00:00:01 UTC
(lldb) po [NSDate dateWithTimeIntervalSince1970:0.6]
1970-01-01 00:00:00 +0000

This patch just always rounds down the seconds value we get from the NSDate object.

Fixes rdar://65084800

Diff Detail

Event Timeline

teemperor created this revision.Jul 6 2020, 6:08 AM
mib accepted this revision.Jul 6 2020, 6:38 AM

LGTM!

This revision is now accepted and ready to land.Jul 6 2020, 6:38 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2020, 8:00 AM