Skip to content

Allow interop between winrt::clock and DateTime with std::chrono::system_clock #697

@DefaultRyan

Description

@DefaultRyan

TimeSpan works well with existing <chrono> based code, because it's a simple std::chrono::duration with no association to a clock type and epoch.

DateTime presents a little more friction. Specifically, it's a std::chrono::time_point<winrt::clock>, and there isn't a standard way to use them with std::chrono::system_clock::time_point. Since they're both referring to "system time" and system_clock is known to use Unix time as its epoch (de facto in C++17, and standard-guaranteed in C++20), it's a simple conversion.

Laying the proper groundwork by implementing to_sys(t) and from_sys(t) on winrt::clock will enable correct manual conversion now, and will power more generalized conversion in C++20.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions