diff --git a/.gitignore b/.gitignore index 253f03c..4651abc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.sw? *.iml deps/ +doc/ ebin/ .eunit/ .idea/ diff --git a/CHANGELOG.markdown b/CHANGELOG.md similarity index 83% rename from CHANGELOG.markdown rename to CHANGELOG.md index f065053..717a517 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ -## 0.7.0 +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 0.7.0 (2021-07-01) * Re-introduce the qdate server for storing qdate timezones, formats, and parsers, rather than overloading the `application` env vars (since the `application` @@ -6,13 +13,13 @@ * Convert to using `qdate_localtime` 1.2.0 (which passes dialyzer checks) * `qdate` is passing dialyzer again -## 0.6.0 +## 0.6.0 (2021-06-01) * Add `age` and `age_days` functions * Add option to preserve millisecond accuracy in date parsing and formatting (@Leonardb) -## 0.5.0 +## 0.5.0 (2019-08-21) * Add `range_X` functions for getting a list of dates/times within a range (such as `range_day/3` to get a range of days between a start and end date. @@ -31,42 +38,42 @@ * Fix Erlang 21 Stacktrace changes (@tnt-dev) * Set a better rebar2 version of erlware commons (@tnt-dev) -## 0.4.2 +## 0.4.2 (2015-11-05) * Add partial support for `ec_date`'s 4-tuple subsecond accuracy time format. * Fix `erlware_commons` dependency to a rebar2-compatible version. -## 0.4.1 +## 0.4.1 (2015-07-26) * Remove unnecessary `io:format` call. -## 0.4.0 +## 0.4.0 (2015-04-30) * Remove dependency on a running server for tracking application state. Instead, parsers and formats are registered to the application environment vars (e.g. `application:get_env`), and timezones are registered to the application environment or the process dictionary. A side-effect of this - change is that you can no longer query another process's timezone. + change is that you can no longer query another process's timezone. * Add basic date arithmetic (e.g. `qdate:add_hours/[1-2]`, etc). * Add `get_formats()` and `get_parsers()` to see list of registered formats and parsers. * Fix bug related to relying on the application environment variable `default_timezone` -## 0.3.0 +## 0.3.0 (2014-05-11) * Add Timezone/Daylight Saving Disambiguation * Add the `auto` timezone shortcut * Fix rebar.config to allow for compilation on Erlang 17 -## 0.2.1 +## 0.2.1 (2013-09-23) * Fix allowing timezone names to be binary -## 0.2.0 +## 0.2.0 (2013-09-12) * Adding `qdate:compare/2,3` for easily comparing dates -## 0.1.0 +## 0.1.0 (2013-04-29) * Initial Release diff --git a/LICENSE b/LICENSE.md similarity index 98% rename from LICENSE rename to LICENSE.md index 7880382..9237482 100644 --- a/LICENSE +++ b/LICENSE.md @@ -1,3 +1,5 @@ +# The MIT License + Copyright (c) 2013 Jesse Gumm Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/README.markdown b/README.md similarity index 97% rename from README.markdown rename to README.md index f2c04ae..a800c63 100644 --- a/README.markdown +++ b/README.md @@ -1,18 +1,23 @@ # qdate - Erlang Date and Timezone Library -[![Build Status](https://travis-ci.org/choptastic/qdate.png?branch=master)](https://travis-ci.org/choptastic/qdate) +[![Build Status](https://img.shields.io/travis/choptastic/qdate/master.svg)](https://travis-ci.org/choptastic/qdate) +[![Hex Version](https://img.shields.io/hexpm/v/qdate.svg)](https://hex.pm/packages/qdate) +[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/qdate/) +[![Total Download](https://img.shields.io/hexpm/dt/qdate.svg)](https://hex.pm/packages/qdate) +[![License](https://img.shields.io/hexpm/l/qdate.svg)](https://github.com/choptastic/qdate/blob/master/LICENSE.md) +[![Last Updated](https://img.shields.io/github/last-commit/choptastic/qdate.svg)](https://github.com/choptastic/qdate/commits/master) ## Purpose Erlang Date and Time management is rather primitive, but improving. -[dh_date](https://github.com/daleharvey/dh_date), of which `ec_date` in +[dh_date](https://github.com/daleharvey/dh_date), of which `ec_date` in [erlware_commons](https://github.com/erlware/erlware_commons) is a fork, is a huge step towards formatting and parsing dates in a way that compares nicely -with PHP's [date](http://php.net/manual/en/function.date.php) and +with PHP's [date](http://php.net/manual/en/function.date.php) and [strtotime](http://php.net/manual/en/function.strtotime.php) functions. -Unfortunately, `ec_date` doesn't deal with timezones, but conveniently, +Unfortunately, `ec_date` doesn't deal with timezones, but conveniently, the project [erlang_localtime](https://github.com/dmitryme/erlang_localtime) does. @@ -92,7 +97,7 @@ two-tuple for `Date` (see "Acceptable Date formats" above). If no timezone is specified or determinable in a `Date` variable, then `qdate` will infer the timezone in the following order. - + If specified by `qdate:set_timezone(Timezone)` for that process. Note, as + + If specified by `qdate:set_timezone(Timezone)` for that process. Note, as specified below (in the "Timezone Functions" section), `set_timezone/1` is a shortcut to `set_timezone(self(), Timezone)`, meaning that `set_timezone/1` only applies to that *specific* process. If none is @@ -506,7 +511,7 @@ the crash. `qdate` ships with an optional relative time parser. To speed up performance (since this parser uses regular expressions), this parser is disabled by default. But if you wish to use it, make sure you call -`qdate:register_parser(parse_relative, fun qdate:parse_relative/1)`. +`qdate:register_parser(parse_relative, fun qdate:parse_relative/1)`. Doing this allows you to parse relative time strings of the following formats: @@ -542,7 +547,7 @@ qdate:between(qdate:add_minutes(-15), Date, qdate:add_minutes(15)). 16> qdate:register_format(longdate, "l, F jS, Y g:i A T"). ok -%% Now, let's try to format our string +%% Now, let's try to format our string 17> LongDateString = qdate:to_string(longdate, DateString). "Saturday, December 21st, 2013 12:24 PM GMT" @@ -568,7 +573,7 @@ Let's see how we do this "Saturday, December 21st, 2013 4:24 AM PST" %% See something interesting there? Yeah, we told it it was PDT, but it output -%% PST. That's because PST is not in daylight saving time in December, and +%% PST. That's because PST is not in daylight saving time in December, and %% `qdate` was able to intelligently infer that, and fix it for us. %% Note, that when in doubt, `qdate` will *not* convert. For example, not all @@ -576,7 +581,7 @@ Let's see how we do this %% will not necessarily convert to EDT. %% However, if you provide the timezone as something like "America/New York", -%% it *will* figure that out, and do the correct conversion for you. +%% it *will* figure that out, and do the correct conversion for you. %% Let's see how it handles unix times with strings that contain timezones. %% If you recall, LongDateString = "Saturday, December 21st, 2013 12:24 PM GMT" @@ -619,7 +624,7 @@ ok %% need to ensure that a date is presented in an appropriate timezone. -%% Let's register some timezones by "Timezone Keys". +%% Let's register some timezones by "Timezone Keys". 25> qdate:set_timezone(my_site, "America/Chicago"). ok 26> qdate:set_timezone({user,1},"Australia/Melbourne"). @@ -713,7 +718,7 @@ midnight on the first day of the current month. qdate can also do a special "beginning" case, particularly the "beginning of the week" calculation. This has three forms, specifically: - + + `beginning_week()` - Returns first day of the current week. + `beginning_week(Date)` - Assumes the beginning of the week is Monday (chosen because Erlang's calendar:day_of_the_week uses 1=Monday and @@ -721,7 +726,7 @@ the week" calculation. This has three forms, specifically: + `beginning_week(DayOfWeek, Date)` - Calculates the beginning of the week based on the provided `DayOfWeek`. Valid values for DayOfWeek are the integers 1-7 or the atom versions of the days of the week. Specifically: - + * Monday: `1 | monday | mon` * Tuesday: `2 | tuesday | tue` * Wednesday: `3 | wednesday | wed` @@ -880,7 +885,7 @@ not exist. ## Changelog -See [CHANGELOG.markdown](https://github.com/choptastic/qdate/blob/master/CHANGELOG.markdown) +See [CHANGELOG.md](https://github.com/choptastic/qdate/blob/master/CHANGELOG.md) ## TODO @@ -906,4 +911,4 @@ Email: gumm@sigma-star.com Twitter: [@jessegumm](http://twitter.com/jessegumm) -Released under the MIT License (see LICENSE file) +Released under the MIT License (see [LICENSE.md](LICENSE.md) file) diff --git a/rebar.config b/rebar.config index de7ef3f..3ac5897 100644 --- a/rebar.config +++ b/rebar.config @@ -12,3 +12,20 @@ erlware_commons, {qdate_localtime, "1.2.0"} ]}. + +{project_plugins, [rebar3_ex_doc]}. + +{ex_doc, [ + {extras, [ + {"CHANGELOG.md", #{title => "Changelog"}}, + {"LICENSE.md", #{title => "License"}}, + {"README.md", #{title => "Overview"}} + ]}, + {main, "README.md"}, + {source_url, "https://github.com/choptastic/qdate"}, + {api_reference, false}, + {skip_undefined_reference_warnings_on, [ + "CHANGELOG.md", + "README.md" + ]} +]}.