Skip to content
Merged
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Elixir CI

on:
pull_request:
branches:
- main
- dev

jobs:
test:
name: Test (Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- elixir: '1.18.4'
otp: '28.0'
version-type: 'strict'
- elixir: '1.12.0'
otp: '24.x'
version-type: 'loose'
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
version-type: ${{ matrix.version-type }}

- name: Install Dependencies
run: mix deps.get

- name: Run Tests
run: mix test
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Added CI workflow to run tests against supported Elixir versions

### Changed

- Updated minimum supported Elixir version to v1.12
- While the library may work with older versions, StreamData supports a
minimum of v1.12, so it would be missing the property tests

### Fixed

- Updated timestamp decoding to be backwards-compatible with Elixir v1.12

## [v1.0.2] - 2025-08-06

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ This section explains how to setup the project locally for development.

### Dependencies

- Elixir `~> 1.7` (OTP 21+)
- Elixir `~> 1.12` (OTP 24+)
- See [Compatibility and
deprecations](https://hexdocs.pm/elixir/1.18.4/compatibility-and-deprecations.html)
for more information

### Get the Source

Expand Down
6 changes: 4 additions & 2 deletions lib/msgpack/decoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ defmodule Msgpack.Decoder do
base_datetime = NaiveDateTime.from_erl!(erlang_datetime)

if nanoseconds > 0 do
NaiveDateTime.add(base_datetime, nanoseconds, :nanosecond)
microseconds = div(nanoseconds, 1000)
%{base_datetime | microsecond: {microseconds, 6}}
else
base_datetime
end
Expand All @@ -250,7 +251,8 @@ defmodule Msgpack.Decoder do
base_datetime = NaiveDateTime.from_erl!(erlang_datetime)

if nanoseconds > 0 do
NaiveDateTime.add(base_datetime, nanoseconds, :nanosecond)
microseconds = div(nanoseconds, 1000)
%{base_datetime | microsecond: {microseconds, 6}}
else
base_datetime
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule MsgpackElixir.MixProject do
[
app: :msgpack_elixir,
version: @version,
elixir: "~> 1.7",
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
deps: deps(),
aliases: aliases(),
Expand Down