Skip to content

Commit

Permalink
Version 2.0.0. See commit details for more info.
Browse files Browse the repository at this point in the history
- New Date, AmbiguousDateTime, and AmbiguousTimezoneInfo types
- All non-bang APIs now return error tuples instead of raising exceptions
- Soft deprecation of abbreviated unit names like :secs
- All unit names are now consistent across the API
- **Breaking**: Removal of ms field of DateTime, replaced with
  millisecond
- **Breaking**: Date API has been moved to Timex module
- Soft deprecation of `from` API, use the new `from_*` variants
- **Breaking**: Removal of DateFormat and DateConvert aliases, use Timex
  module instead.
- Reorganization of the codebase to be more sane
- Rewrite of all typespecs and docs
- APIs are now very strict about validating arguments, invalid arguments
  will produce an error tuple like {:error, term}.
- Many more tests
- Major improvements to the shifting and diffing code
  • Loading branch information
bitwalker committed Mar 6, 2016
1 parent 8908f19 commit 28ef48f
Show file tree
Hide file tree
Showing 78 changed files with 6,199 additions and 3,840 deletions.
Empty file added .github/ISSUE_TEMPLATE.md
Empty file.
Empty file.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ _build/
erl_crash.dump
bench/snapshots
priv/tmp_downloads
cover/
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
language: elixir
sudo: false
elixir:
- 1.0.5
- 1.1.0
- 1.2.0
otp_release:
- 18.0
- 18.1
script:
- "MIX_ENV=test mix do deps.get, compile, coveralls.travis"
after_script:
- mix deps.get --only docs
- MIX_ENV=docs mix inch.report
- mix deps.get
- MIX_ENV=test mix inch.report
notifications:
recipients:
- [email protected]
53 changes: 52 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,58 @@
All notable changes to this project will be documented in this file (at least to the extent possible, I am not infallible sadly).
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
## 2.0.0

**READ THIS**: This release contains breaking changes from the previous API. The changes are easy to make,
and the compiler will catch almost all of them. See the Migrating section of the README for details on migrating
to 2.0

### Added
- New `Date` type, which is basically the same as `DateTime`, but without time/timezone, which works with
most all API functions that work with DateTimes, except those which are specific to time or timezones.
Functions which take a Date or DateTime and options which can manipulate both date and time properties,
like `set` or `shift` will work as you'd expect with Date values and time-based properties (setting a time
property will change nothing, shifting will work for values which represent at least a day, sub-day values will not
change the Date).
- New `AmbiguousDateTime` type which is returned instead of `DateTime` when the datetime in question falls in
an ambiguously defined timezone period. This type contains two fields, `:before` and `:after` which contain
the `DateTime` values to choose from. This handles cases where previously an error would likely have been thrown,
or the behaviour would've been undefined.
- Timex.date and Timex.datetime, which are the equivalent of the old Date.from, except produce a Date or DateTime respectively.
The `from` API still exists in the Date and DateTime modules, and is present in the Timex API for easier migration, but will
be deprecated in the future.
- New `from_erl`, `from_timestamp`, `from_microseconds`, `from_milliseconds`, `from_seconds`, `from_days` functions to
replace the old `from` API, and to match the `Time` API more closely.
- to_date/to_datetime/to_unix/to_timestamp/to_gregorian_seconds conversions in Timex.Convertable (old Timex.Date.Convert protocol)
- before?/after?/between? functions to Timex module
- format/format!/format_time/format_time!/parse/parse! API to Timex module
- week_of_month/1 and /3 to get the week index of the month a date occurs in
- `Timex.diff(this, other, :calendar_weeks)` - get the diff between two dates in terms of weeks on the calendar,
in other words, the diff is done based on the start of the earliest date's week, and the end of the latest date's week
### Changed
- **BREAKING** All non-bang functions in the API now return error tuples of the form `{:error, term}` instead of raising exceptions
- **BREAKING** All DateTime-related APIs can now return an `AmbiguousDateTime`, which must be handled by choosing which DateTime to use.
- **BREAKING** All Timezone lookups can now return an `AmbiguousTimezoneInfo` struct, which must be handled by choosing which TimezoneInfo to use.
- **BREAKING** DateTime.ms is now DateTime.millisecond
- **BREAKING** Date module API has moved to Timex module
- Date and DateTime modules now contain their respective implementations of the Timex API, all shared functions
have moved to the Timex module. You can work with Date or DateTimes either through the Timex API, or through the
API exposed in the Date and DateTime modules. It is recommended to use Timex though.
- **BREAKING** Renamed Timex.Date.Convert to Timex.Convertable
- **BREAKING** `diff/3` now returns the same value no matter which order the arguments are given. Use `compare/3` to get the ordering
### Deprecated
- `Timex.from` (old `Date.from`) variants. Use `Timex.date`, `Timex.datetime`, `Date.from_<type>`, or `DateTime.from_<type>` instead.
- `DateTime.from`. Use `Timex.datetime`, `DateTime.from_erl`, `DateTime.from_<type>`
- `to_usecs`, `to_msecs`, `to_secs`, and `to_mins` in favor of `to_microseconds`, `to_milliseconds`, `to_seconds`, and `to_minutes`
- Abbreviated unit names like `secs` or `mins`, `sec` or `min`, in favor of their full names (i.e. `seconds`, `minutes`, etc.)
### Removed
- DateConvert/DateFormat aliases
### Fixed
- Shifting datetimes is now far more accurate than it was previously, and handles timezone changes, ambiguous timezone periods, and non-existent time periods (such as those during a timezone change like DST).
- Diffing by weeks, months, and years is now much more precise
- Humanized Time formatter now pluralizes units correctly

## 1.0.2

**BREAKING**: If you previously depended on parsing of timezone abbreviations for non-POSIX zones,
for example, CEST, you will need to update your code to manually map that abbreviation to a valid zone
Expand Down
15 changes: 5 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,13 @@ in making it happen.

Timex is composed of the following general components:

- The tzdata Parser Expression Grammar (PEG), its associated mix task, and the
current tzdata Erlang module produced by the PEG. This is used for parsing the
raw Olson Timezone Database. (not yet on master)
- The `Timex.Date` namespace, containing the `DateTime` struct, `DateTime` conversions,
and the `Date` API.
- The `Timex` module, which is the primary API for the library
- The `Timex.Date` module, which is where all `Date` specific APIs reside
- The `Timex.DateTime` module, which is where all `DateTime` specific APIs reside
- The `Timex.Time` namespace, containing the `Time` API as well as the Time formatting API.
- The `Timex.DateFormat` namespace, containing all code related to formatting `DateTime` values.
- The `Timex.Format` namespace, containing all code related to string formatting.
This includes the behavior for custom formatting plugins.
- The `Timex.Parsers.DateFormat` namespace, containing all code related to parsing `DateTime` values
from other formats (namely strings at this point). This includes the behavior for custom parsing plugins.
- The `Timex.Parsers.ZoneInfo` namespace, containing all code related to parsing zoneinfo files.
- The `Timex.Utils` namespace, containing all general utility code used throughout Timex.
- The `Timex.Parse` namespace, containing all code related to parsing.
- The `Timex.Timezone` namespace, containing all code related to the parsing of tzdata, querying timezones,
determining the local timezone for a given date, etc.

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The MIT License (MIT)

## Copyright (c) 2013 Alexei Sholik, Paul Schoenfelder
## Copyright (c) 2016 Paul Schoenfelder

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 28ef48f

Please sign in to comment.