# Sales pitch
If you've ever had to parse datetime input from multiple sources
and everyone's standardized on ISO8601, you might have found out
that that's not quite as standard as you'd wish. This is where
datefmt helps you.
auto expected = SysTime(Date(2010, 1, 1), UTC());
foreach (date; ["2010-01-01", "2010-01-01T00:00:00", "2010-01-01
assert(tryParse(date, ISO8601FORMAT, parsed));
assert(expected == parsed);
# How does datefmt's parsing differ from dateparser?
dateparser is great when you have a date that's in some arbitrary
format and you want to turn it into a sensible date. It's perfect
for manual input.
datefmt is good when you have a restricted set of formats you
need to accept and want to reject everything else -- generally
when a wide range of systems using the same somewhat nebulous
standard emit the stuff you need to parse.
# What about formatting?
datefmt can do formatting too! Most of its formatting options are
taken from strftime, so it should be generally familiar.
And of course you can use predefined formats for RFC1123 and
auto st = SysTime(DateTime(2010, 4, 12, 15, 30, 00), UTC());
// Mon, 12 Apr 2010 15:30:00 Z
# Is anyone using it?
I've been using this in my RSS reader for the past month or two,
during which time it's been exposed to a number of horrible
variants of both RFC1123 and ISO8601.
# How do I get it?
Add "datefmt": "~>1.0.0" to your dub.json and Bob's your uncle!
Or download the single file from
https://raw.githubusercontent.com/dhasenan/datefmt/master/source/datefmt.d and put it in your project.
Licensed under MS-PL (BSD-style permissive license with patent
grant); open an issue at
https://github.com/dhasenan/datefmt/issues if you need a