andrewMacmurray/elm-concurrent-task/1.1.1

NOTE: the latest version is 2.0.0

ConcurrentTask.Time

Drop in replacements for elm/time's's Tasks.

The JavaScript runner has these tasks builtin by default. If needed they can be overridden like so:

NOTE: The custom examples are the same as the built-in implementations.

import * as ConcurrentTask from "@andrewmacmurray/elm-concurrent-task"


ConcurrentTask.register({
  tasks: {},
  ports: app.ports,
  builtins: {
    timeNow: customTimeNow,
    timeZoneOffset: customTimeZoneOffset,
    timeZoneName: customTimeZoneName,
  }
});


function customTimeNow(): number {
  return Date.now()
}


function customTimeZoneOffset(): number {
  return -new Date().getTimezoneOffset();
}


function customTimeZoneName(): string | number {
  try {
    return Intl.DateTimeFormat().resolvedOptions().timeZone;
  } catch (e) {
    return new Date().getTimezoneOffset();
  }
}
now : ConcurrentTask x Posix

Get the POSIX time at the moment when this task is run.

A direct replacement for elm/time's Time.now.

here : ConcurrentTask x Zone

Produce a Zone based on the current UTC offset.

A direct replacement for elm/time's Time.here.

getZoneName : ConcurrentTask x ZoneName

Use Intl.DateTimeFormat().resolvedOptions().timeZone to try to get names like Europe/Moscow or America/Havana.

A direct replacement for elm/time's Time.getZoneName.