Skip to content

Commit d49aeff

Browse files
committed
Update documentation
1 parent 9c1ea4c commit d49aeff

File tree

7 files changed

+156
-29
lines changed

7 files changed

+156
-29
lines changed

CODE_OF_CONDUCT.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

CONTRIBUTING.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Contributing
2+
3+
To run tests:
4+
```shell
5+
$ # This will run tests, regenerate EXAMPLES.md, and run Credo in strict mode
6+
$ mix tests
7+
```
8+
9+
To build a release:
10+
```shell
11+
$ # bin/release {old_version} {new_version}
12+
$ bin/release 0.0.1 0.0.2
13+
```
14+
15+
Please review and agree to the [code of conduct](./CODE_OF_CONDUCT.md) before
16+
contributing.

LICENSE.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
TODO
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018 David Bernheisel
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# DateTimeParser
22

3+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE.md)
4+
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](./CODE_OF_CONDUCT.md)
5+
36
DateTimeParser is a tokenizer for strings that attempts to parse into a
47
DateTime, NaiveDateTime if timezone is not determined, Date, or Time.
58

@@ -71,18 +74,12 @@ end
7174

7275
## Changelog
7376

74-
[View changelog](./CHANGELOG.md)
77+
[View Changelog](./CHANGELOG.md)
7578

7679
## Contributing
7780

78-
To run tests:
79-
```shell
80-
$ # This will run tests, regenerate EXAMPLES.md, and run Credo in strict mode
81-
$ mix tests
82-
```
81+
[How to contribute](./CONTRIBUTING.md)
8382

84-
To build a release:
85-
```shell
86-
$ # bin/release {old_version} {new_version}
87-
$ bin/release 0.0.1 0.0.2
88-
```
83+
## Special Thanks
84+
85+
[<img src="https://www.taxjar.com/img/lander/logo.svg" height=75 />](https://www.taxjar.com)

bin/release

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
2+
# Usage: ./bin/release {old_version} {new_version}
23
set -e
34

45
previous_version="${1}"

lib/date_time_parser.ex

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule DateTimeParser do
22
@moduledoc """
33
DateTimeParser is a tokenizer for strings that attempts to parse into a
4-
DateTime, NaiveDateTime if timezone is not determined, Date, or Time.
4+
`DateTime`, `NaiveDateTime` if timezone is not determined, `Date`, or `Time`.
55
66
The biggest ambiguity between datetime formats is whether it's `ymd` (year month
77
day), `mdy` (month day year), or `dmy` (day month year); this is resolved by
@@ -30,7 +30,7 @@ defmodule DateTimeParser do
3030
3131
iex> DateTimeParser.parse_datetime("1/1/18 3:24 PM", assume_utc: true)
3232
{:ok, DateTime.from_naive!(~N[2018-01-01T15:24:00Z], "Etc/UTC")}
33-
# or ~U[2018-01-01T15:24:00Z] in 1.9.0+
33+
# or ~U[2018-01-01T15:24:00Z] in Elixir 1.9.0+
3434
3535
iex> DateTimeParser.parse_datetime(~s|"Dec 1, 2018 7:39:53 AM PST"|)
3636
{:ok, DateTime.from_naive!(~N[2018-12-01T14:39:53Z], "Etc/UTC")}
@@ -113,11 +113,12 @@ defmodule DateTimeParser do
113113
"""
114114
@spec parse_date(String.t() | nil) :: {:ok, Date.t()} | {:error, String.t()}
115115
def parse_date(string) when is_binary(string) do
116-
parser = if String.contains?(string, "/") do
117-
&DateTimeParser.Date.parse_us/1
118-
else
119-
&DateTimeParser.Date.parse/1
120-
end
116+
parser =
117+
if String.contains?(string, "/") do
118+
&DateTimeParser.Date.parse_us/1
119+
else
120+
&DateTimeParser.Date.parse/1
121+
end
121122

122123
with {:ok, tokens, _, _, _, _} <- string |> clean |> parser.(),
123124
{:ok, date} <- to_date(tokens),
@@ -183,16 +184,23 @@ defmodule DateTimeParser do
183184
end
184185

185186
defp validate_day(%{day: day, month: month} = date)
186-
when month in [1, 3, 5, 7, 8, 10, 12] and day in 1..31, do: {:ok, date}
187+
when month in [1, 3, 5, 7, 8, 10, 12] and day in 1..31,
188+
do: {:ok, date}
189+
187190
defp validate_day(%{day: day, month: month} = date)
188-
when month in [4, 6, 9, 11] and day in 1..30, do: {:ok, date}
191+
when month in [4, 6, 9, 11] and day in 1..30,
192+
do: {:ok, date}
193+
189194
defp validate_day(%{day: day, month: 2} = date)
190-
when day in 1..28, do: {:ok, date}
195+
when day in 1..28,
196+
do: {:ok, date}
197+
191198
defp validate_day(%{day: 29, month: 2, year: year} = date) do
192199
if Timex.is_leap?(year),
193200
do: {:ok, date},
194201
else: :error
195202
end
203+
196204
defp validate_day(_), do: :error
197205

198206
defp maybe_convert_to_utc(%NaiveDateTime{} = naive_datetime, opts) do

mix.exs

+16-7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ defmodule DateTimeParser.MixProject do
77
app: :date_time_parser,
88
name: "DateTimeParser",
99
version: @version,
10+
homepage_url: "https://hexdocs.pm/date_time_parser",
1011
source_url: "https://github.com/taxjar/date_time_parser",
11-
homepage_url: "https://github.com/taxjar/date_time_parser",
1212
elixir: ">= 1.3.0",
1313
elixirc_paths: elixirc_paths(Mix.env()),
1414
aliases: aliases(),
@@ -21,7 +21,7 @@ defmodule DateTimeParser.MixProject do
2121
profile: :bench
2222
],
2323
deps: deps(),
24-
description: "Parse a string into %DateTime{}, %NaiveDateTime{}, %Time{}, or %Date{}"
24+
description: "Parse a string into `%DateTime{}`, `%NaiveDateTime{}`, `%Time{}`, or `%Date{}`"
2525
]
2626
end
2727

@@ -36,13 +36,22 @@ defmodule DateTimeParser.MixProject do
3636

3737
defp package do
3838
[
39-
files: ["lib", "mix.exs", "CHANGELOG*", "README*", "LICENSE*", "EXAMPLES*"],
39+
files: [
40+
"lib",
41+
"mix.exs",
42+
"CODE_OF_CONDUCT*",
43+
"CHANGELOG*",
44+
"README*",
45+
"LICENSE*",
46+
"EXAMPLES*"
47+
],
48+
organization: "taxjar",
4049
maintainers: ["David Bernheisel"],
41-
licenses: [],
50+
licenses: ["MIT"],
4251
links: %{
4352
"GitHub" => "https://github.com/taxjar/date_time_parser",
44-
"readme" => "https://github.com/taxjar/date_time_parser/blob/#{@version}/README.md",
45-
"changelog" => "https://github.com/taxjar/date_time_parser/blob/#{@version}/CHANGELOG.md"
53+
"Readme" => "https://github.com/taxjar/date_time_parser/blob/#{@version}/README.md",
54+
"Changelog" => "https://github.com/taxjar/date_time_parser/blob/#{@version}/CHANGELOG.md"
4655
}
4756
]
4857
end
@@ -70,7 +79,7 @@ defmodule DateTimeParser.MixProject do
7079

7180
defp docs() do
7281
[
73-
main: "readme",
82+
main: "DateTimeParser",
7483
source_ref: @version,
7584
extras: [
7685
"README.md",

0 commit comments

Comments
 (0)