File tree Expand file tree Collapse file tree 6 files changed +79
-4
lines changed
test/API/functionalities/data-formatter/swift/date Expand file tree Collapse file tree 6 files changed +79
-4
lines changed Original file line number Diff line number Diff line change @@ -1256,22 +1256,28 @@ 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 ;
1264- tm_epoch.tm_hour = 0 ;
12651266 tm_epoch.tm_min = 0 ;
1266- tm_epoch.tm_mon = 0 ;
1267+ tm_epoch.tm_hour = 0 ;
12671268 tm_epoch.tm_mday = 1 ;
1269+ tm_epoch.tm_mon = 0 ;
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 @@ -37,6 +37,14 @@ bool lldb_private::formatters::swift::Date_SummaryProvider(
3737
3838 ValueObjectSP time_sp (valobj.GetChildAtNamePath ({g__time}));
3939
40+ #ifdef _WIN32
41+ static ConstString g__timeIntervalSinceReferenceDate (
42+ " _timeIntervalSinceReferenceDate" );
43+ if (!time_sp)
44+ time_sp = valobj.GetChildAtNamePath (
45+ {g__timeIntervalSinceReferenceDate, " _value" });
46+ #endif
47+
4048 if (!time_sp)
4149 return false ;
4250
Original file line number Diff line number Diff line change @@ -670,8 +670,16 @@ 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" ),
673+ " Foundation.Date summary provider" ,
674+ ConstString (" Foundation(Essentials)?\\ .Date" ),
675+ TypeSummaryImpl::Flags (summary_flags).SetDontShowChildren (true ), true );
676+
677+ #ifdef _WIN32
678+ lldb_private::formatters::AddCXXSummary (
679+ swift_category_sp, lldb_private::formatters::swift::Date_SummaryProvider,
680+ " Foundation.NSDate summary provider" , ConstString (" Foundation.NSDate" ),
674681 TypeSummaryImpl::Flags (summary_flags).SetDontShowChildren (true ));
682+ #endif
675683
676684 lldb_private::formatters::AddCXXSummary (
677685 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+ @swiftTest
15+ def test_swift_date_formatters (self ):
16+ """Test Date summary strings."""
17+ self .build ()
18+
19+ _ = lldbutil .run_to_source_breakpoint (
20+ self , "break here" , lldb .SBFileSpec ("main.swift" )
21+ )
22+
23+ self .expect (
24+ "v date" ,
25+ startstr = "(Foundation.Date) date = 1999-11-05 23:17:00 UTC" ,
26+ )
27+
28+ if sys .platform != "win32" :
29+ return
30+
31+ self .expect (
32+ "v nsdate" ,
33+ startstr = "(Foundation.NSDate) date = 1999-11-05 23:17:00 UTC" ,
34+ )
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 = 1999
7+ comps. month = 11
8+ comps. day = 6
9+ comps. hour = 0
10+ comps. minute = 17
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