Skip to content

Commit 3d1b3bf

Browse files
committed
Update README
1 parent b63a86a commit 3d1b3bf

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ To use timex with your projects, edit your mix.exs file and add it as a dependen
99

1010
```elixir
1111
defp deps do
12-
[{:timex, "~> 0.13.4"}]
12+
[{:timex, "~> 0.14.0"}]
1313
end
1414
```
1515

@@ -19,7 +19,7 @@ To use Timex modules without the Timex namespace, add `use Timex` to the top of
1919

2020
The goal of this project is to provide a complete set of Date/Time functionality for Elixir projects, with the hope of being eventually merged into the standard library.
2121

22-
The `Date` module is for dealing with dates, which includes time and timezone information for those dates. It supports getting current date in any time zone, converting between timezones while taking Daylight Savings Time offsets into account, calculating time intervals between two dates, shifting a date by some amount of seconds/hours/days/years towards past and future, etc. As Erlang provides support only for the Gregorian calendar, that's what timex currently supports, but it is possible to add additional calendars if needed.
22+
The `Date` module is for dealing with dates, which includes time and timezone information for those dates. It supports getting current date in any time zone, converting between timezones while taking zone offset changes into account, calculating time intervals between two dates, shifting a date by some amount of seconds/hours/days/years towards past and future, etc. As Erlang provides support only for the Gregorian calendar, that's what timex currently supports, but it is possible to add additional calendars if needed.
2323

2424
The `Time` module supports a finer grained level of arithmetic over time intervals. It is intended for use as timestamps in logs, measuring code execution times, converting time units, etc.
2525

@@ -44,7 +44,7 @@ Since Erlang's native date format doesn't carry any time zone information, `Date
4444
```elixir
4545
datetime = {{2013,3,17},{21,22,23}}
4646

47-
date = Date.from(datetime) # datetime is assumed to be in UTC by default
47+
date = Date.from(datetime) # datetime is assumed to be in UTC by default
4848
DateFormat.format!(date, "{RFC1123}") #=> "Sun, 17 Mar 2013 21:22:23 GMT"
4949

5050
date = Date.from(datetime, "CST") # With a provided timezone
@@ -56,7 +56,11 @@ Date.local(date) # convert date to local time zone (CST for our example)
5656
#=> %DateTime{year: 2013, month: 3, day: 17, hour: 15, minute: 22, second: 23, timezone: ...}
5757

5858
# Let's see what happens if we switch the time zone
59-
date = Timezone.convert(date, Timezone.get("EST"))
59+
60+
# You must provide a DateTime or Erlang datetime tuple when getting a Timezone,
61+
# this is to ensure that the right period for that zone is retrieved, if you omit
62+
# the date, `Date.now` is used, which is not guaranteed to be correct.
63+
converted = Timezone.convert(date, "America/New_York")
6064
DateFormat.format!(date, "{RFC1123}")
6165
#=> "Sun, 17 Mar 2013 17:22:23 EST"
6266

@@ -81,8 +85,6 @@ date = Date.now
8185
Date.universal(date) #=> %DateTime{...}
8286
# Convert a date to local time
8387
Date.local(date) #=> %DateTime{...}
84-
# Convert a date to local time, and provide the local timezone
85-
Date.local(date, Date.timezone("PST")) #=> %DateTime{...}
8688
```
8789

8890
### Extracting information about dates
@@ -198,13 +200,11 @@ Parsing dates is also a breeze with `DateFormat`:
198200

199201
```elixir
200202
# Parse a date using the default parser
201-
gmt = Date.timezone("GMT")
202-
date = Date.from({{2013,3,5},{23,25,19}}, gmt)
203+
date = Date.from({{2013,3,5},{23,25,19}}, "GMT")
203204
{:ok, ^date} = DateFormat.parse("Tue, 05 Mar 2013 23:25:19 GMT", "{RFC1123}")
204205

205206
# Any preformatted directive ending in `z` will shift the date to UTC/Zulu
206-
gmt = Date.timezone("EET")
207-
date = Date.from({{2013,3,5},{23,25,19}})
207+
date = Date.from({{2013,3,5},{23,25,19}}, "Europe/Athens")
208208
{:ok, ^date} = DateFormat.parse("Tue, 05 Mar 2013 23:25:19 +0200", "{RFC1123z}")
209209

210210
# Simple date format, default parser
@@ -331,7 +331,7 @@ Use `Date.diff` to obtain the number of seconds, minutes, hours, days, months, w
331331

332332
Full support for retreiving local timezone configuration on OSX, *NIX, and Windows, conversion to any timezone in the Olson timezone database, and full support for daylight savings time transitions.
333333

334-
Timezone support is also exposed via the `Timezone`, `Timezone.Local`, and `Timezone.Dst` modules. Their functionality is exposed via the `Date` module's API, and most common use cases shouldn't need to access the `Timezone` namespace directly, but it's there if needed.
334+
Timezone support is also exposed via the `Timezone`, `Timezone.Local` modules. Their functionality is exposed via the `Date` module's API, and most common use cases shouldn't need to access the `Timezone` namespace directly, but it's there if needed.
335335

336336
## License
337337

0 commit comments

Comments
 (0)