Skip to content

Error Parsing String With AM/PM #7

@carc1n0gen

Description

@carc1n0gen

I may very well be doing something incorrectly, but there seems to be a bug when parsing a date/time with AM/PM at the end

Sample Code

import std.stdio;

import datefmt;

void main()
{
    string dateStr = "2026-02-11 03:33 AM";
    auto observationTime = dateStr.parse("%Y-%m-%d %I:%M %p");
    writeln(observationTime.format("%H:%M"));
}

Error

object.Exception@../../../../.dub/packages/datefmt/1.0.4/datefmt/source/datefmt.d(166): trailing data: AM
----------------
../../../../.dub/packages/datefmt/1.0.4/datefmt/source/datefmt.d:166 @safe std.datetime.systime.SysTime datefmt.parse(immutable(char)[], immutable(char)[], immutable(std.datetime.timezone.TimeZone), bool) [0x565248df7537]
source/app.d:16 _Dmain [0x565248dd6ba0]

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