<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Enh, I would tend to prefer Jesse’s <i>qdate</i> because it is pure Erlang.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Cheers,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>DBM<o:p></o:p></span></p></div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> erlang-questions-bounces@erlang.org [mailto:erlang-questions-bounces@erlang.org] <b>On Behalf Of </b>Dmitrii Dimandt<br><b>Sent:</b> Tuesday, April 30, 2013 01:50<br><b>To:</b> Jesse Gumm<br><b>Cc:</b> Erlang Questions<br><b>Subject:</b> Re: [erlang-questions] [ANN] qdate - Unified Date Formatting/Parsing and Timezone Management<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Have you also looked at tempo, <a href="https://github.com/selectel/tempo">https://github.com/selectel/tempo</a> ?<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Your library and tempo could probably be combined<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p><div><div><div><p class=MsoNormal>On Apr 30, 2013, at 07:09 , Jesse Gumm wrote:<o:p></o:p></p></div><p class=MsoNormal><br><br><o:p></o:p></p><div><p class=MsoNormal>Hello Erlangers,<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I'm proud to announce the beta release (v0.1.0) of "qdate" - a unified date parsing/formatting and timezone management utility for Erlang.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Blog post describing my thoughts that went into its development<o:p></o:p></p></div><div><p class=MsoNormal><a href="http://sigma-star.com/blog/post/qdate" target="_blank">http://sigma-star.com/blog/post/qdate</a><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Source code on GitHub (includes a README that covers all the functionality)<o:p></o:p></p></div><div><p class=MsoNormal><a href="https://github.com/choptastic/qdate" target="_blank">https://github.com/choptastic/qdate</a><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>At its core, qdate is basically a wrapper around ec_date (fork of dh_date and part of erlware_commons) and erlang_localtime.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>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 needing it).<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Briefly, here's what it does:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>* Easily convert from any date format to any other date format: datetime(), now(), unix timestamp, and formatted date strings (list and binaries) are all acceptable:<o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:to_string("Y-m-d g:ia", Date).</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> "2012-12-21 5:51pm"</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:to_string(<<"Y-m-d g:ia">>, Date).</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> <<"2012-12-21 5:51pm">></span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:to_unixtime(Date).</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> 1356112260</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:to_date(Date).</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> {{2012,12,21},{17,51,0}}</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:to_now(Date).</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> {1356,112260,0}</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> % Note, that the argument `Date` can be anything </span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> % that's a Date/Time Format (datetime Tuple, now tuple,</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> % Integer (unixtime), or string ("2012-12-21 5:51pm")</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>* Extends ec_date's formatting functions to include PHP's timezone-related characters:<o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:to_string("Y-m-d g:ia T", Date)</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> "2012-12-21 5:51pm CST"</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>* Able to pre-parse timezones from text strings, and convert from one timezone to another:<o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> % Read Timezone from string, convert to datetime in EST</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:to_date("2012-12-21 5:51pm CST","EST").</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> {{2012,12,21},{18,51,0}}</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> % Read timezone from string, convert to a string in EST</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:to_string("n/j/Y g:ia T","2012-12-21 5:51pm CST", "EST").</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> "12/21/2012 6:51pm EST"</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>* Register timezones with the qdate server by a key (to make a timezone alias) or by pid():<o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> %% Set timezone for the current process to GMT</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:set_timezone("GMT").</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> %% Set timezone for some_key to HKT</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:set_timezone(some_key, "HKT").</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>* Register custom formatting strings with the qdate server, for quick reference.<o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:register_format(long_date, "l, F jS, Y g:i A T").</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> ok</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:to_string(long_date,1356133860).</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> "Friday, December 21st, 2012 11:51 PM GMT"</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>* Register custom parsing functions with the qdate server, to be transparently used for conversion.<o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:register_parser(weird_format, fun parse_esoteric_format/1).</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> ok</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> > qdate:to_date("20121221.115100").</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> {{2012,12,21},{11,51,00}}</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>* Attempt to maintain API compatibility with ec_date by supporting qdate:parse, qdate:nparse, and qdate:format.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I hope some of you find this useful in your apps.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>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.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Thanks, and I hope everyone has a glorious day or evening or whatever timezone you happen to be in.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><div><p class=MsoNormal>-- <br>Jesse Gumm<br>Owner, Sigma Star Systems<br><a href="tel:414.940.4866" target="_blank">414.940.4866</a> || <a href="http://sigma-star.com/" target="_blank">sigma-star.com</a> || @jessegumm <o:p></o:p></p></div></div></div><p class=MsoNormal>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br><a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></div></div></body></html>