Upgrade to Pro — share decks privately, control downloads, hide ads and more …

タイムゾーンの†闇†

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

 タイムゾーンの†闇†

社内のプレゼン大会でしゃべった(10分相当)

Avatar for sylph01

sylph01

May 25, 2017
Tweet

More Decks by sylph01

Other Decks in How-to & DIY

Transcript

  1. ྫ s1 = {{2017, 5, 25}, {0, 0, 0}} |>

    :calendar.datetime_to_gregorian_seconds Tzdata.periods_for_time("Asia/Tokyo", s1, :utc) # [%{from: %{standard: 61589206800, utc: 61589174400, wall: 61589206800}, # std_off: 0, until: %{standard: :max, utc: :max, wall: :max}, utc_off: 32400, # zone_abbr: "JST"}] ࠓ೔ͷ೔෇͸Asia/TokyoͰ͸౰વJSTɺUTC offset͸32400ඵ(+9h)
  2. ྫ s2 = {{1948, 5, 3}, {0, 0, 0}} |>

    :calendar.datetime_to_gregorian_seconds Tzdata.periods_for_time("Asia/Tokyo", s2, :utc) # [%{from: %{standard: 61483456800, utc: 61483424400, wall: 61483460400}, # std_off: 3600, # until: %{standard: 61494858000, utc: 61494825600, wall: 61494861600}, # utc_off: 32400, zone_abbr: "JDT"}] JSTͷ1948೥5݄2೔0:00ΑΓՆ࣌ؒద༻ͳͷͰɺUTCͰͷ1948/5/3 0:00͸Ն࣌ؒద༻ൣғɻJDTͱ͍͏λΠϜκʔϯʂ
  3. ྫ s3 = :calendar.datetime_to_gregorian_seconds({{2017 ,11, 5}, {1, 30, 0}}) Tzdata.periods_for_time("America/Los_Angeles",

    s3, :wall) # [%{from: %{standard: 63656503200, utc: 63656532000, wall: 63656506800}, # std_off: 3600, # until: %{standard: 63677062800, utc: 63677091600, wall: 63677066400}, # utc_off: -28800, zone_abbr: "PDT"}, # %{from: %{standard: 63677062800, utc: 63677091600, wall: 63677062800}, # std_off: 0, # until: %{standard: 63687952800, utc: 63687981600, wall: 63687952800}, # utc_off: -28800, zone_abbr: "PST"}] wall clock͕2017೥11݄5೔ 01:30Λࢦ࣌͢ࠁ͸PST 01:30ͱPDT 01:30ͷ2͕ͭ͋Γ͏Δɻ
  4. Erlang/Elixirͷ࣌ࠁϥΠϒϥ Ϧ͕͠ΜͲ͍ iex(3)> Calendar.DateTime.from_erl {{2017, 11, 5}, {8, 30, 0}},

    "America/Los_Angeles" {:ok, %DateTime{calendar: Calendar.ISO, day: 5, hour: 8, microsecond: {0, 0}, minute: 30, month: 11, second: 0, std_offset: 0, time_zone: "America/Los_Angeles", utc_offset: -28800, year: 2017, zone_abbr: "PST"}}
  5. Erlang/Elixirͷ࣌ࠁϥΠϒϥ Ϧ͕͠ΜͲ͍ iex(4)> Calendar.DateTime.from_erl {{2017, 11, 5}, {1, 30, 0}},

    "America/Los_Angeles" {:ambiguous, %Calendar.AmbiguousDateTime{possible_date_times: [%DateTime{calendar: Calendar.ISO, day: 5, hour: 1, microsecond: {0, 0}, minute: 30, month: 11, second: 0, std_offset: 3600, time_zone: "America/Los_Angeles", utc_offset: -28800, year: 2017, zone_abbr: "PDT"}, %DateTime{calendar: Calendar.ISO, day: 5, hour: 1, microsecond: {0, 0}, minute: 30, month: 11, second: 0, std_offset: 0, time_zone: "America/Los_Angeles", utc_offset: -28800, year: 2017, zone_abbr: "PST"}]}}