[erlang-questions] [ANN] qdate - Unified Date Formatting/Parsing and Timezone Management
Tue Apr 30 07:09:50 CEST 2013
I'm proud to announce the beta release (v0.1.0) of "qdate" - a unified date
parsing/formatting and timezone management utility for Erlang.
Blog post describing my thoughts that went into its development
Source code on GitHub (includes a README that covers all the functionality)
At its core, qdate is basically a wrapper around ec_date (fork of dh_date
and part of erlware_commons) and erlang_localtime.
But it's much more than just a wrapper. It's the complete date and time
utility I feel is greatly needed in the Erlang world (since I found myself
Briefly, here's what it does:
* Easily convert from any date format to any other date format: datetime(),
now(), unix timestamp, and formatted date strings (list and binaries) are
> qdate:to_string("Y-m-d g:ia", Date).
> qdate:to_string(<<"Y-m-d g:ia">>, Date).
% Note, that the argument `Date` can be anything
% that's a Date/Time Format (datetime Tuple, now tuple,
% Integer (unixtime), or string ("2012-12-21 5:51pm")
* Extends ec_date's formatting functions to include PHP's timezone-related
> qdate:to_string("Y-m-d g:ia T", Date)
"2012-12-21 5:51pm CST"
* Able to pre-parse timezones from text strings, and convert from one
timezone to another:
% Read Timezone from string, convert to datetime in EST
> qdate:to_date("2012-12-21 5:51pm CST","EST").
% Read timezone from string, convert to a string in EST
> qdate:to_string("n/j/Y g:ia T","2012-12-21 5:51pm CST", "EST").
"12/21/2012 6:51pm EST"
* Register timezones with the qdate server by a key (to make a timezone
alias) or by pid():
%% Set timezone for the current process to GMT
%% Set timezone for some_key to HKT
> qdate:set_timezone(some_key, "HKT").
* Register custom formatting strings with the qdate server, for quick
> qdate:register_format(long_date, "l, F jS, Y g:i A T").
"Friday, December 21st, 2012 11:51 PM GMT"
* Register custom parsing functions with the qdate server, to be
transparently used for conversion.
> qdate:register_parser(weird_format, fun parse_esoteric_format/1).
* Attempt to maintain API compatibility with ec_date by supporting
qdate:parse, qdate:nparse, and qdate:format.
I hope some of you find this useful in your apps.
Any issues, comments, complaints, bug reports, whatever, feel free to post
in this thread, make a github issue, shoot me a message on twitter
(@jessegumm) or email me directly.
Thanks, and I hope everyone has a glorious day or evening or whatever
timezone you happen to be in.
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions