Skip to content

[ML] Investigate replacing CTimeUtils with functionality from <chrono> #1252

Open
@droberts195

Description

@droberts195

The functionality we have in the core::CTimeUtils class was written before C++ had time functionality, when we had to use the C library functions.

It may be possible to modernise this class now, or even completely remove it.

One argument for not removing it altogether would be that the <chrono> functionality is verbose, and there may be benefits to wrapping it up.

For example, instead of:

     std::int64_t timestamp{std::chrono::duration_cast<std::chrono::milliseconds>(
                                std::chrono::system_clock::now().time_since_epoch())
                                .count()};

we could have:

     std::int64_t timestamp{core::CTimeUtils::nowMs()};

Another thing to consider is timezone support. Windows does timezones different to *nix, and support for timezones via the Microsoft C runtime library is pretty bad. For this reason we use Boost.DateTime for timezones on Windows, but the C runtime on *nix (because the *nix C runtime is better than Boost.DateTime, which in turn is better than Microsoft's C runtime). However, if Microsoft's C++ date/time functionality is better at handling timezones correctly then we may be able to simplify all this by switching to C++ functionality.

The task here is first some investigation to assess C++ library functionality and platform differences, then possibly some refactoring if it would greatly reduce the code complexity.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions