TILT- TimeZone -part 22

To see if two TILTS are in the same day, it is not enough to see if the difference is less than one day. Could be less than 1 day in UTC – but in Europe/Bucharest can be the next day ( suppose that I put one TILT at 23:59:59 local time – the next TILT could be in 2 seconds )

In JavaScript one can have the IANA codes ( https://en.wikipedia.org/wiki/List_of_tz_database_time_zones ) by

Intl.DateTimeFormat().resolvedOptions().timeZone

In C# there I am receiving this and convert to TimeZoneInfo

var tz = TimeZoneInfo.FindSystemTimeZoneById(timeZone);
if (tz == null)
    return NotFound("cannot find timezone:" + timeZone);
var ser = tz.ToSerializedString();

Also, now we can verify to see that the time zone difference is ok

var tz = TimeZoneInfo.FromSerializedString(timezone);
if (tz == null)
    throw new TimeZoneNotFoundException(" cannote deserialize " + timezone);

var localTimeNow= TimeZoneInfo.ConvertTimeFromUtc(dateNowUTC, tz);

And the fact that I was thinking later – that means

  1. Database modification ( alter table , update )

  2. Backend verifications modified

  3. Sending data modified

  4. Tests added

And , of course, does not work in production . Added Hellang.Middleware.ProblemDetails to can debug more easy the error ( instead of 500 )

That comes from updating the existing database with default values

So reverting to the default timezone ( e.g. Europe/Bucharest) and now the tests are failing into CI ( that has not the time zone , being a stripped linux)

Adding to the CI

- name: Setup timezone
    uses: zcong1993/setup-timezone@master
    with:
    timezone: Asia/Shanghai

and now it works

Tools used

Visual Studio

Visual Studio Code

SSMS

Hellang.Middleware.ProblemDetails

zcong1993/setup-timezone@master