Skip to content

Commit

Permalink
add some UTC clarification for timestamps (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregors authored Jul 17, 2024
1 parent 7d875e2 commit 410c4d5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ See [Mariaex Compatibility](https://github.com/elixir-ecto/myxql/blob/master/MAR
| `date` | `~D[2013-10-12]` (2) |
| `time` | `~T[00:37:14]` (3) |
| `datetime` | `~N[2013-10-12 00:37:14]` (2), (4) |
| `timestamp` | `~U[2013-10-12 00:37:14Z]` (2), (4) |
| `timestamp` | `~U[2013-10-12 00:37:14Z]` (2), (4), (7) |
| `json` | `%{"foo" => "bar"}` (5) |
| `char` | `"é"` |
| `text` | `"myxql"` |
Expand All @@ -115,6 +115,8 @@ remember to use TEXT column for your JSON field.

6. See "Geometry support" section below

7. See "UTC required" section below

## JSON support

MyXQL comes with JSON support via the [Jason](https://github.com/michalmuskala/jason) library.
Expand Down Expand Up @@ -147,6 +149,23 @@ shouldn't be used.
If you're using MyXQL geometry types with Ecto and need to for example accept a WKT format as user
input, consider implementing an [custom Ecto type](https://hexdocs.pm/ecto/Ecto.Type.html).

## UTC required

When using `DateTime` type, MyXQL assumes the server is configured with the UTC time
zone. If that is not the case, set it manually with `MyXQL.start_link/1` and
`:after_connect` option:

```elixir
MyXQL.start_link(after_connect: &MyXQL.query!(&1, "SET time_zone = '+00:00'"))
```

or when configuring `Ecto.Repo`:

```elixir
config :myapp, MyApp.Repo,
after_connect: {MyXQL, :query!, ["SET time_zone = '+00:00'", []]}
```

## Contributing

Run tests:
Expand Down

0 comments on commit 410c4d5

Please sign in to comment.