Skip to content

Date::fromDbStringLocal() fails if time is missing #375

@Baxulio

Description

@Baxulio

Description

The function trantor::Date::fromDbStringLocal() expects a full timestamp string in the format: "YYYY-MM-DD HH:MM:SS[.ffffff]", but if you pass only a date string like "1970-01-01", it fails silently and returns an invalid Date object, which can lead to confusing behavior.

Example

std::string s = trantor::Date().toDbStringLocal();  // "1970-01-01"
auto d = trantor::Date::fromDbStringLocal(s);
LOG_DEBUG << d.toDbStringLocal();  // Outputs: 1899-00--1

Expected Behavior

The parser should either support "YYYY-MM-DD" as a valid input by assuming zero time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions