Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.sw?
*.iml
deps/
doc/
ebin/
.eunit/
.idea/
Expand Down
29 changes: 18 additions & 11 deletions CHANGELOG.markdown → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
## 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`
module only wants keys to be atoms).
* 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.
Expand All @@ -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
2 changes: 2 additions & 0 deletions LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
33 changes: 19 additions & 14 deletions README.markdown → README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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"

Expand All @@ -568,15 +573,15 @@ 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
%% places in Eastern Standard Time do daylight saving time, and as such, EST
%% 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"
Expand Down Expand Up @@ -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").
Expand Down Expand Up @@ -713,15 +718,15 @@ 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
7=Sunday).
+ `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`
Expand Down Expand Up @@ -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

Expand All @@ -906,4 +911,4 @@ Email: [email protected]

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)
17 changes: 17 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]}
]}.