Skip to content

Commit

Permalink
Add visualizer for std::chrono::system_clock::time_point
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Oct 8, 2024
1 parent faccf00 commit fb061d7
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions stl/debugger/STL.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -2312,4 +2312,57 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
</Expand>
</Type>

<Type Name="std::chrono::time_point&lt;std::chrono::system_clock,std::chrono::duration&lt;__int64,std::ratio&lt;1,10000000&gt; &gt; &gt;">
<!--
Same computation as in std::chrono::year_month_day::_Civil_from_days
and https://howardhinnant.github.io/date_algorithms.html#civil_from_days.
-->
<Intrinsic Name="z" Expression="(_MyDur._MyRep / (24 * 60 * 60 * 10000000ull)) + 719468"/>
<Intrinsic Name="era" Expression="(z() &gt;= 0 ? z() : z() - 146096) / 146097"/>
<Intrinsic Name="doe" Expression="(unsigned)(z() - era() * 146097)"/>
<Intrinsic Name="yoe" Expression="(doe() - doe()/1460 + doe()/36524 - doe()/146096) / 365"/>
<Intrinsic Name="doy" Expression="doe() - (365*yoe() + yoe()/4 - yoe()/100)"/>
<Intrinsic Name="mp" Expression="(5*doy() + 2)/153"/>
<Intrinsic Name="day" Expression="doy() - (153*mp()+2)/5 + 1"/>
<Intrinsic Name="month" Expression="mp() &lt; 10 ? mp()+3 : mp()-9"/>
<Intrinsic Name="year" Expression="((long long)yoe()) + era() * 400 + (month() &lt; 2)"/>

<DisplayString Condition="_MyDur._MyRep &gt;= 0">
{year()}-{month()/10}{month()%10}-{day()/10}{day()%10} {
(_MyDur._MyRep % (24 * 60 * 60 * 10000000ull))/(10 * 60 * 60 * 10000000ull)
}{
((_MyDur._MyRep % (24 * 60 * 60 * 10000000ull))/(60 * 60 * 10000000ull)) % 10
}:{
(_MyDur._MyRep % (60 * 60 * 10000000ull))/(10 * 60 * 10000000ull)
}{
(_MyDur._MyRep % (10 * 60 * 10000000ull)) / (60 * 10000000ull)
}:{
(_MyDur._MyRep % (60 * 10000000ull)) / (10 * 10000000ull)
}{
(_MyDur._MyRep % (10 * 10000000ull)) / 10000000ull
}.{
(_MyDur._MyRep % 10000000) / 1000000
}{
(_MyDur._MyRep % 1000000) / 100000
}{
(_MyDur._MyRep % 100000) / 10000
}{
(_MyDur._MyRep % 10000) / 1000
}{
(_MyDur._MyRep % 1000) / 100
}{
(_MyDur._MyRep % 100) / 10
}{
_MyDur._MyRep % 10
}
</DisplayString>
<Expand>
<Item Name="[ns/100]">_MyDur._MyRep</Item>
<Item Name="[us]">_MyDur._MyRep/10</Item>
<Item Name="[ms]">_MyDur._MyRep/(10 * 1000)</Item>
<Item Name="[s]">_MyDur._MyRep/(10 * 1000 * 1000)</Item>
<Synthetic Name="[clock]"><DisplayString>UTC</DisplayString></Synthetic>
</Expand>
</Type>

</AutoVisualizer>

0 comments on commit fb061d7

Please sign in to comment.