diff --git a/CHANGELOG.md b/CHANGELOG.md index 5470dd7a..6341431e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Nakama: `ISession.CreateTime` now accurately represents Unix time in seconds since the `ISession` object was created. ## [3.12.0] - 2024-04-08 ### Added diff --git a/Nakama.Tests/AuthenticateTest.cs b/Nakama.Tests/AuthenticateTest.cs index 064b2d44..453d80bb 100644 --- a/Nakama.Tests/AuthenticateTest.cs +++ b/Nakama.Tests/AuthenticateTest.cs @@ -41,6 +41,7 @@ public async Task ShouldAuthenticateCustomId() Assert.NotNull(session.UserId); Assert.NotNull(session.Username); Assert.False(session.IsExpired); + Assert.Equal(DateTimeOffset.UtcNow.ToUnixTimeSeconds(), session.CreateTime); } [Fact(Timeout = TestsUtil.TIMEOUT_MILLISECONDS)] diff --git a/Nakama/Session.cs b/Nakama/Session.cs index d9d070ec..40256bd1 100644 --- a/Nakama/Session.cs +++ b/Nakama/Session.cs @@ -85,8 +85,7 @@ public override string ToString() internal Session(string authToken, string refreshToken, bool created) { Created = created; - var span = DateTime.UtcNow - Epoch; - CreateTime = span.Seconds; + CreateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); RefreshExpireTime = 0L; Vars = new Dictionary();