Skip to content

Commit a5d66bd

Browse files
authored
Add visualizer for std::chrono::system_clock::time_point (#5005)
1 parent e0ad9c3 commit a5d66bd

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

stl/debugger/STL.natvis

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,4 +2312,57 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
23122312
</Expand>
23132313
</Type>
23142314

2315+
<Type Name="std::chrono::time_point&lt;std::chrono::system_clock,std::chrono::duration&lt;__int64,std::ratio&lt;1,10000000&gt; &gt; &gt;">
2316+
<!--
2317+
Same computation as in std::chrono::year_month_day::_Civil_from_days
2318+
and https://howardhinnant.github.io/date_algorithms.html#civil_from_days.
2319+
-->
2320+
<Intrinsic Name="z" Expression="(_MyDur._MyRep / (24 * 60 * 60 * 10000000ull)) + 719468"/>
2321+
<Intrinsic Name="era" Expression="(z() &gt;= 0 ? z() : z() - 146096) / 146097"/>
2322+
<Intrinsic Name="doe" Expression="(unsigned)(z() - era() * 146097)"/>
2323+
<Intrinsic Name="yoe" Expression="(doe() - doe()/1460 + doe()/36524 - doe()/146096) / 365"/>
2324+
<Intrinsic Name="doy" Expression="doe() - (365*yoe() + yoe()/4 - yoe()/100)"/>
2325+
<Intrinsic Name="mp" Expression="(5*doy() + 2)/153"/>
2326+
<Intrinsic Name="day" Expression="doy() - (153*mp()+2)/5 + 1"/>
2327+
<Intrinsic Name="month" Expression="mp() &lt; 10 ? mp()+3 : mp()-9"/>
2328+
<Intrinsic Name="year" Expression="((long long)yoe()) + era() * 400 + (month() &lt; 2)"/>
2329+
2330+
<DisplayString Condition="_MyDur._MyRep &gt;= 0">
2331+
{year(),d}-{month()/10,d}{month()%10,d}-{day()/10,d}{day()%10,d} {
2332+
(_MyDur._MyRep % (24 * 60 * 60 * 10000000ull))/(10 * 60 * 60 * 10000000ull),d
2333+
}{
2334+
((_MyDur._MyRep % (24 * 60 * 60 * 10000000ull))/(60 * 60 * 10000000ull)) % 10,d
2335+
}:{
2336+
(_MyDur._MyRep % (60 * 60 * 10000000ull))/(10 * 60 * 10000000ull),d
2337+
}{
2338+
(_MyDur._MyRep % (10 * 60 * 10000000ull)) / (60 * 10000000ull),d
2339+
}:{
2340+
(_MyDur._MyRep % (60 * 10000000ull)) / (10 * 10000000ull),d
2341+
}{
2342+
(_MyDur._MyRep % (10 * 10000000ull)) / 10000000ull,d
2343+
}.{
2344+
(_MyDur._MyRep % 10000000) / 1000000,d
2345+
}{
2346+
(_MyDur._MyRep % 1000000) / 100000,d
2347+
}{
2348+
(_MyDur._MyRep % 100000) / 10000,d
2349+
}{
2350+
(_MyDur._MyRep % 10000) / 1000,d
2351+
}{
2352+
(_MyDur._MyRep % 1000) / 100,d
2353+
}{
2354+
(_MyDur._MyRep % 100) / 10,d
2355+
}{
2356+
_MyDur._MyRep % 10,d
2357+
}
2358+
</DisplayString>
2359+
<Expand>
2360+
<Item Name="[ns/100]">_MyDur._MyRep</Item>
2361+
<Item Name="[us]">_MyDur._MyRep/10</Item>
2362+
<Item Name="[ms]">_MyDur._MyRep/(10 * 1000)</Item>
2363+
<Item Name="[s]">_MyDur._MyRep/(10 * 1000 * 1000)</Item>
2364+
<Synthetic Name="[clock]"><DisplayString>UTC</DisplayString></Synthetic>
2365+
</Expand>
2366+
</Type>
2367+
23152368
</AutoVisualizer>

0 commit comments

Comments
 (0)