File tree Expand file tree Collapse file tree 6 files changed +70
-3
lines changed
test/API/functionalities/data-formatter/swift/date Expand file tree Collapse file tree 6 files changed +70
-3
lines changed Original file line number Diff line number Diff line change @@ -1256,9 +1256,11 @@ bool lldb_private::formatters::ObjCSELSummaryProvider(
12561256// this call gives the POSIX equivalent of the Cocoa epoch
12571257time_t lldb_private::formatters::GetOSXEpoch () {
12581258 static time_t epoch = 0 ;
1259+ #ifndef _AIX
12591260 if (!epoch) {
1260- #if !defined( _WIN32) && !defined(_AIX)
1261+ #ifndef _WIN32
12611262 tzset ();
1263+ #endif
12621264 tm tm_epoch;
12631265 tm_epoch.tm_sec = 0 ;
12641266 tm_epoch.tm_hour = 0 ;
@@ -1267,11 +1269,15 @@ time_t lldb_private::formatters::GetOSXEpoch() {
12671269 tm_epoch.tm_mday = 1 ;
12681270 tm_epoch.tm_year = 2001 - 1900 ;
12691271 tm_epoch.tm_isdst = -1 ;
1272+ #ifdef _WIN32
1273+ epoch = _mkgmtime (&tm_epoch);
1274+ #else
12701275 tm_epoch.tm_gmtoff = 0 ;
12711276 tm_epoch.tm_zone = nullptr ;
12721277 epoch = timegm (&tm_epoch);
12731278#endif
12741279 }
1280+ #endif
12751281 return epoch;
12761282}
12771283
Original file line number Diff line number Diff line change @@ -34,9 +34,15 @@ using namespace lldb_private::formatters::swift;
3434bool lldb_private::formatters::swift::Date_SummaryProvider (
3535 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
3636 static ConstString g__time (" _time" );
37+ static ConstString g__timeIntervalSinceReferenceDate (
38+ " _timeIntervalSinceReferenceDate" );
3739
3840 ValueObjectSP time_sp (valobj.GetChildAtNamePath ({g__time}));
3941
42+ if (!time_sp)
43+ time_sp = valobj.GetChildAtNamePath (
44+ {g__timeIntervalSinceReferenceDate, " _value" });
45+
4046 if (!time_sp)
4147 return false ;
4248
Original file line number Diff line number Diff line change @@ -670,8 +670,9 @@ LoadFoundationValueTypesFormatters(lldb::TypeCategoryImplSP swift_category_sp) {
670670
671671 lldb_private::formatters::AddCXXSummary (
672672 swift_category_sp, lldb_private::formatters::swift::Date_SummaryProvider,
673- " Foundation.Date summary provider" , ConstString (" Foundation.Date" ),
674- TypeSummaryImpl::Flags (summary_flags).SetDontShowChildren (true ));
673+ " Foundation.Date summary provider" ,
674+ ConstString (" Foundation(Essentials)?\\ .(NS)?Date" ),
675+ TypeSummaryImpl::Flags (summary_flags).SetDontShowChildren (true ), true );
675676
676677 lldb_private::formatters::AddCXXSummary (
677678 swift_category_sp,
Original file line number Diff line number Diff line change 1+ SWIFT_SOURCES := main.swift
2+
3+ include Makefile.rules
Original file line number Diff line number Diff line change 1+ """
2+ Test Foundation.Date summary strings.
3+ """
4+
5+ import lldb
6+ from lldbsuite .test .lldbtest import *
7+ from lldbsuite .test .decorators import *
8+ import lldbsuite .test .lldbutil as lldbutil
9+
10+ import sys
11+
12+
13+ class TestCase (TestBase ):
14+ @skipUnlessFoundation
15+ @swiftTest
16+ def test_swift_date_formatters (self ):
17+ """Test Date summary strings."""
18+ self .build ()
19+
20+ _ = lldbutil .run_to_source_breakpoint (
21+ self , "break here" , lldb .SBFileSpec ("main.swift" )
22+ )
23+
24+ self .expect (
25+ "v date" ,
26+ startstr = "(Foundation.Date) date = 2001-01-15 13:12:00 UTC" ,
27+ )
28+
29+ if sys .platform != "win32" :
30+ return
31+
32+ self .expect (
33+ "v nsdate" ,
34+ startstr = "(Foundation.NSDate) date = 2001-01-15 13:12:00 UTC" ,
35+ )
Original file line number Diff line number Diff line change 1+ import Foundation
2+
3+ let paris = TimeZone ( identifier: " Europe/Paris " ) !
4+
5+ var comps = DateComponents ( )
6+ comps. year = 2001
7+ comps. month = 1
8+ comps. day = 15
9+ comps. hour = 14
10+ comps. minute = 12
11+ comps. timeZone = paris
12+
13+ let date = Calendar ( identifier: . gregorian) . date ( from: comps) !
14+ let nsdate = date as NSDate
15+
16+ print ( " break here " )
You can’t perform that action at this time.
0 commit comments