11# qdate - Erlang Date and Timezone Library
22
3- [ ![ Build Status] ( https://travis-ci.org/choptastic/qdate.png?branch=master )] ( https://travis-ci.org/choptastic/qdate )
3+ [ ![ Build Status] ( https://img.shields.io/travis/choptastic/qdate/master.svg )] ( https://travis-ci.org/choptastic/qdate )
4+ [ ![ Hex Version] ( https://img.shields.io/hexpm/v/qdate.svg )] ( https://hex.pm/packages/qdate )
5+ [ ![ Hex Docs] ( https://img.shields.io/badge/hex-docs-lightgreen.svg )] ( https://hexdocs.pm/qdate/ )
6+ [ ![ Total Download] ( https://img.shields.io/hexpm/dt/qdate.svg )] ( https://hex.pm/packages/qdate )
7+ [ ![ License] ( https://img.shields.io/hexpm/l/qdate.svg )] ( https://github.com/choptastic/qdate/blob/master/LICENSE.md )
8+ [ ![ Last Updated] ( https://img.shields.io/github/last-commit/choptastic/qdate.svg )] ( https://github.com/choptastic/qdate/commits/master )
49
510## Purpose
611
712Erlang Date and Time management is rather primitive, but improving.
813
9- [ dh_date] ( https://github.com/daleharvey/dh_date ) , of which ` ec_date ` in
14+ [ dh_date] ( https://github.com/daleharvey/dh_date ) , of which ` ec_date ` in
1015[ erlware_commons] ( https://github.com/erlware/erlware_commons ) is a fork, is a
1116huge step towards formatting and parsing dates in a way that compares nicely
12- with PHP's [ date] ( http://php.net/manual/en/function.date.php ) and
17+ with PHP's [ date] ( http://php.net/manual/en/function.date.php ) and
1318[ strtotime] ( http://php.net/manual/en/function.strtotime.php ) functions.
1419
15- Unfortunately, ` ec_date ` doesn't deal with timezones, but conveniently,
20+ Unfortunately, ` ec_date ` doesn't deal with timezones, but conveniently,
1621the project [ erlang_localtime] ( https://github.com/dmitryme/erlang_localtime )
1722does.
1823
@@ -92,7 +97,7 @@ two-tuple for `Date` (see "Acceptable Date formats" above).
9297If no timezone is specified or determinable in a ` Date ` variable, then ` qdate `
9398will infer the timezone in the following order.
9499
95- + If specified by ` qdate:set_timezone(Timezone) ` for that process. Note, as
100+ + If specified by ` qdate:set_timezone(Timezone) ` for that process. Note, as
96101 specified below (in the "Timezone Functions" section), ` set_timezone/1 ` is
97102 a shortcut to ` set_timezone(self(), Timezone) ` , meaning that
98103 ` set_timezone/1 ` only applies to that * specific* process. If none is
183188
184189#### Conversion Functions provided for API compatibility with ` ec_date `
185190
186- + ` parse/1 ` - Same as ` to_date(Date) `
187- + ` nparse/1 ` - Same as ` to_now(Date) `
188- + ` format/1 ` - Same as ` to_string/1 `
189- + ` format/2 ` - Same as ` to_string/2 `
191+ + ` parse/1 ` - Same as ` ec_date: to_date(Date)`
192+ + ` nparse/1 ` - Same as ` ec_date: to_now(Date)`
193+ + ` format/1 ` - Same as ` ec_date: to_string/1`
194+ + ` format/2 ` - Same as ` ec_date: to_string/2`
190195
191196### Date and Time Comparison
192197
@@ -506,7 +511,7 @@ the crash.
506511` qdate ` ships with an optional relative time parser. To speed up performance
507512(since this parser uses regular expressions), this parser is disabled by
508513default. But if you wish to use it, make sure you call
509- ` qdate:register_parser(parse_relative, fun qdate:parse_relative/1) ` .
514+ ` qdate:register_parser(parse_relative, fun qdate:parse_relative/1) ` .
510515
511516Doing this allows you to parse relative time strings of the following formats:
512517
@@ -542,7 +547,7 @@ qdate:between(qdate:add_minutes(-15), Date, qdate:add_minutes(15)).
54254716 > qdate :register_format (longdate , " l, F jS, Y g:i A T" ).
543548ok
544549
545- % % Now, let's try to format our string
550+ % % Now, let's try to format our string
54655117 > LongDateString = qdate :to_string (longdate , DateString ).
547552" Saturday, December 21st, 2013 12:24 PM GMT"
548553
@@ -568,15 +573,15 @@ Let's see how we do this
568573" Saturday, December 21st, 2013 4:24 AM PST"
569574
570575% % See something interesting there? Yeah, we told it it was PDT, but it output
571- % % PST. That's because PST is not in daylight saving time in December, and
576+ % % PST. That's because PST is not in daylight saving time in December, and
572577% % `qdate` was able to intelligently infer that, and fix it for us.
573578
574579% % Note, that when in doubt, `qdate` will *not* convert. For example, not all
575580% % places in Eastern Standard Time do daylight saving time, and as such, EST
576581% % will not necessarily convert to EDT.
577582
578583% % However, if you provide the timezone as something like "America/New York",
579- % % it *will* figure that out, and do the correct conversion for you.
584+ % % it *will* figure that out, and do the correct conversion for you.
580585
581586% % Let's see how it handles unix times with strings that contain timezones.
582587% % If you recall, LongDateString = "Saturday, December 21st, 2013 12:24 PM GMT"
619624% % need to ensure that a date is presented in an appropriate timezone.
620625
621626
622- % % Let's register some timezones by "Timezone Keys".
627+ % % Let's register some timezones by "Timezone Keys".
62362825 > qdate :set_timezone (my_site , " America/Chicago" ).
624629ok
62563026 > qdate :set_timezone ({user ,1 }," Australia/Melbourne" ).
@@ -713,15 +718,15 @@ midnight on the first day of the current month.
713718
714719qdate can also do a special "beginning" case, particularly the "beginning of
715720the week" calculation. This has three forms, specifically:
716-
721+
717722 + ` beginning_week() ` - Returns first day of the current week.
718723 + ` beginning_week(Date) ` - Assumes the beginning of the week is Monday
719724 (chosen because Erlang's calendar: day_of_the_week uses 1=Monday and
720725 7=Sunday).
721726 + ` beginning_week(DayOfWeek, Date) ` - Calculates the beginning of the week
722727 based on the provided ` DayOfWeek ` . Valid values for DayOfWeek are the
723728 integers 1-7 or the atom versions of the days of the week. Specifically:
724-
729+
725730 * Monday: ` 1 | monday | mon `
726731 * Tuesday: ` 2 | tuesday | tue `
727732 * Wednesday: ` 3 | wednesday | wed `
@@ -880,7 +885,7 @@ not exist.
880885
881886## Changelog
882887
883- See [ CHANGELOG.markdown ] ( https://github.com/choptastic/qdate/blob/master/CHANGELOG.markdown )
888+ See [ CHANGELOG.md ] ( https://github.com/choptastic/qdate/blob/master/CHANGELOG.md )
884889
885890## TODO
886891
@@ -906,4 +911,4 @@ Email: gumm@sigma-star.com
906911
907912Twitter: [ @jessegumm ] ( http://twitter.com/jessegumm )
908913
909- Released under the MIT License (see LICENSE file)
914+ Released under the MIT License (see [ LICENSE.md ] ( LICENSE.md ) file)
0 commit comments