www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17558] New: DateTime should support custom user-provided


          Issue ID: 17558
           Summary: DateTime should support custom user-provided
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich 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..

Jun 26 2017