Skip to content

Support %- variant for strftime #87

@tbm

Description

@tbm

I just found out that you can use %- to strip leading zeros, e.g.

$ date +%Y/%-m/%d
2019/1/16

Unfortunately, this is not supported by DateTime::Format::Strptime:

use DateTime::Format::Strptime qw(strftime);

my $date = DateTime::Format::Strptime->new(
    pattern  =>  "%Y/%-m/%d",
    on_error => "croak",
);

my $p = $date->parse_datetime("2015/5/30");
print strftime("%F", $p), "\n" if $p;

Metadata

Metadata

Assignees

No one assigned

    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