Formatting dates in std.datetime?

Stewart Gordon smjg_1998 at yahoo.com
Sat Apr 21 04:30:29 PDT 2012


On 20/04/2012 21:29, H. S. Teoh wrote:
> Is there a way to format std.datetime.Date objects with a custom format
> string?

My utility library has a datetime module with a custom formatting facility.

http://pr.stewartsplace.org.uk/d/sutil/

The format string scheme is one of my own design, using repeated-letter format specifiers 
similar to those found in some other schemes, and designed to be logical, natural-looking, 
extensible and easy to remember.

It doesn't currently have functions to convert between its types and those in 
std.datetime, but it's straightforward to construct a DateTimeComponents from a 
std.datetime.Date structure and then call its format method, if you still want to use the 
std.datetime API and just use my library for formatting.

> In particular, I'd like to reuse month short names defined in
> std.datetime, but it appears that the names are private. I'd really
> rather not duplicate them by hand, if there's a way to get them.
<snip>

My library has these arrays public.  But I agree that it was somewhat gratuitous to make 
them private in std.datetime.

Stewart.


More information about the Digitalmars-d-learn mailing list