[Lldb-commits] [PATCH] D83221: [lldb] Always round down in NSDate's formatter to match NSDate's builtin format
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 6 12:54:10 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5814255e1a7d: [lldb] Always round down in NSDate's formatter to match NSDate's builtin format (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83221/new/
https://reviews.llvm.org/D83221
Files:
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py
lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
Index: lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
===================================================================
--- lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
+++ lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
@@ -655,6 +655,14 @@
[NSDate dateWithTimeIntervalSinceReferenceDate:
floor([[NSDate date] timeIntervalSinceReferenceDate])];
+ NSDate *date_1970_minus_06 = [NSDate dateWithTimeIntervalSince1970:-0.6];
+ NSDate *date_1970_minus_05 = [NSDate dateWithTimeIntervalSince1970:-0.5];
+ NSDate *date_1970_minus_04 = [NSDate dateWithTimeIntervalSince1970:-0.4];
+
+ NSDate *date_1970_plus_06 = [NSDate dateWithTimeIntervalSince1970:0.6];
+ NSDate *date_1970_plus_05 = [NSDate dateWithTimeIntervalSince1970:0.5];
+ NSDate *date_1970_plus_04 = [NSDate dateWithTimeIntervalSince1970:0.4];
+
CFAbsoluteTime date1_abs = CFDateGetAbsoluteTime(date1);
CFAbsoluteTime date2_abs = CFDateGetAbsoluteTime(date2);
CFAbsoluteTime date3_abs = CFDateGetAbsoluteTime(date3);
Index: lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py
===================================================================
--- lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py
@@ -43,6 +43,15 @@
self.expect('frame variable date4_abs', substrs=['1970'])
self.expect('frame variable date5_abs', substrs=[now_year])
+ # Check that LLDB always follow's NSDate's rounding behavior (which
+ # is always rounding down).
+ self.expect_expr("date_1970_minus_06", result_summary="1969-12-31 23:59:59 UTC")
+ self.expect_expr("date_1970_minus_05", result_summary="1969-12-31 23:59:59 UTC")
+ self.expect_expr("date_1970_minus_04", result_summary="1969-12-31 23:59:59 UTC")
+ self.expect_expr("date_1970_plus_06", result_summary="1970-01-01 00:00:00 UTC")
+ self.expect_expr("date_1970_plus_05", result_summary="1970-01-01 00:00:00 UTC")
+ self.expect_expr("date_1970_plus_04", result_summary="1970-01-01 00:00:00 UTC")
+
self.expect('frame variable cupertino home europe',
substrs=['@"America/Los_Angeles"',
'@"Europe/Rome"',
Index: lldb/source/Plugins/Language/ObjC/Cocoa.cpp
===================================================================
--- lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -867,7 +867,7 @@
// is generally true and POSIXly happy, but might break if a library vendor
// decides to get creative
time_t epoch = GetOSXEpoch();
- epoch = epoch + (time_t)date_value;
+ epoch = epoch + static_cast<time_t>(std::floor(date_value));
tm *tm_date = gmtime(&epoch);
if (!tm_date)
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83221.275717.patch
Type: text/x-patch
Size: 2987 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200706/91d6abcb/attachment-0001.bin>
More information about the lldb-commits
mailing list