为 UTC `DateTime` 调用`Timex.Timezone.get/2` 时`Timex.Timezone.resolve/3` 中出现`FunctionClauseError` 错误

`FunctionClauseError` error in `Timex.Timezone.resolve/3` when calling `Timex.Timezone.get/2` for a UTC `DateTime`

我有(我怀疑是)UTC 日期时间。我想将其转换为我的当地时间(该日期时间 的时区名为 America/New_York )。

我试图关注 the Timex docs:

> timezone = Timezone.get("America/Chicago", Timex.now)
#<TimezoneInfo(America/Chicago - CDT (-06:00:00))>

> Timezone.convert(datetime, timezone)
#<DateTime(2016-02-29T06:30:30.120-06:00 America/Chicago)>

为什么下面显示的第三条命令会引发错误?

iex(1)> ~N[2019-12-02 16:27:18]                
~N[2019-12-02 16:27:18]
iex(2)> DateTime.from_naive(v(1), "Etc/UTC")
{:ok, #DateTime<2019-12-02 16:27:18Z>}
iex(3)> timezone = Timex.Timezone.get("America/New_York", v(2))
** (FunctionClauseError) no function clause matching in Timex.Timezone.resolve/3    

    The following arguments were given to Timex.Timezone.resolve/3:

        # 1
        "America/New_York"

        # 2
        {:error, :invalid_date}

        # 3
        :wall

    Attempted function clauses (showing 1 out of 1):

        def resolve(name, seconds_from_zeroyear, utc_or_wall) when is_binary(name) and is_integer(seconds_from_zeroyear) and (utc_or_wall === :wall or utc_or_wall === :utc)

    (timex) lib/timezone/timezone.ex:356: Timex.Timezone.resolve/3
iex(3)> timezone = Timex.Timezone.get("America/New_York")      
#<TimezoneInfo(America/New_York - EST (-05:00:00))>

第四条命令有效,但 'timezone'(同名)now 并不总是任何日期时间的 'same' 时区。这似乎模棱两可。 The Wikipedia article listing the tz database time zones 状态:

The UTC DST offset is different from the UTC offset for zones where daylight saving time is observed (see individual time zone pages for details).

这意味着时区(相对)'fixed';任何给定时区的任何特定日期时间的偏移量都是变化的。

但如果这是真的,令人困惑的是 Timex.Timezone.get/2 甚至 接受 日期时间值作为参数。为什么时区名称不仅足够而且非常全面?通过 名称和日期时间检索时区有什么意义?

我是个白痴!

在失败的命令中:

timezone = Timex.Timezone.get("America/New_York", v(2))

v(2) 具有值 {:ok, #DateTime<2019-12-02 16:27:18Z>},即它是一个元组 包含 一个 DateTime.

我应该做的:

iex(5)> {:ok, datetime} = v(2)
{:ok, #DateTime<2019-12-02 16:27:18Z>}
iex(6)> timezone = Timex.Timezone.get("America/New_York", datetime)
#<TimezoneInfo(America/New_York - EST (-05:00:00))>
iex(7)> Timex.Timezone.convert(datetime, timezone)
#DateTime<2019-12-02 11:27:18-05:00 EST America/New_York>