UTC DateTime

Hex.pm Build Status Coverage Status Hex.pm

A datetime implementation constraint to UTC.

Goal

The goal is to create datetime type, which unlike DateTime guarantees to be UTC only, without ignoring the existence of timezones like a NaiveDateTime.

A secondary goal is to be more efficient or at least on par with the build in datetimes. (DateTime, NaiveDateTime) In practice the goal is to use less memory and perform common [shared] actions faster.

Quick Setup

iex> UTCDateTime.utc_now
~Z[2019-12-14 16:08:13.042407]
iex> UTCDateTime.from_rfc3339!("2019-12-14T16:08:13.042407+01:00")
~Z[2019-12-14 15:08:13.042407]
iex> UTCDateTime.from_iso8601!("2019-12-14 16:08:13.042407")
~Z[2019-12-14 16:08:13.042407]

Installation

The package can be installed by adding utc_datetime to your list of dependencies in mix.exs:

def deps do
[
{:utc_datetime, "~> 0.0.5"}
]
end

The docs can be found at https://hexdocs.pm/utc_datetime.

Integration

Ecto

Hex.pm

Integrates with Ecto as a timestamp type.

Example:

defmodule User do
use Ecto.Schema
@timestamps_opts [type: UTCDateTime]
schema "users" do
field :name, :string
timestamps()
end
...

or alternatively

schema "users" do
field :name, :string
timestamps(type: UTCDateTime)
end

Changelog

v0.0.5 (2019-12-15)

New Features:

v0.0.4 (2019-12-15)

New Features:

v0.0.3 (2019-12-15)

New Features:

v0.0.2 (2019-12-15)

New Features:

v0.0.1 (2019-12-14)

Base UTCDateTime.

New Features:

Experimental:

Additional:

Roadmap

Copyright (c) 2019, Ian Luites.

UTCDateTime code is licensed under the MIT License.