[Issue 17558] New: DateTime should support custom user-provided formatting
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jun 26 04:46:38 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17558
Issue ID: 17558
Summary: DateTime should support custom user-provided
formatting
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: andrej.mitrovich at gmail.com
Currently there's a collection of formatting functions, but each one follows
some predefined standard, such as:
- toSimpleString
- toISOString
- toISOExtString
However if you want your own formatting, you have to do everything manually
currently, which is a pain. Here's what I envision the API to be like:
------
//
auto time = SysTime(...); // imagine it's 2017-02-03 14:10:50
auto formatted = time.toFormattedString("YYYY-MM-DD HH:MM");
assert(formatted == "2017-02-03 14:10");
auto formatted = time.toFormattedString("YYYY-MM HHh");
assert(formatted == "2017-02 14h");
------
The exact formatting strings defined aren't important to me, but having the
ability to output certain information I want in a certain format is important -
e.g. leaving out seconds, using numbers instead of words for months, etc..
--
More information about the Digitalmars-d-bugs
mailing list