Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
タイムゾーンの†闇†
Search
sylph01
May 25, 2017
How-to & DIY
250
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
タイムゾーンの†闇†
社内のプレゼン大会でしゃべった(10分相当)
sylph01
May 25, 2017
Transcript
40 slides
λΠϜκʔϯͷ†ҋ† Ryo Kajiwara, 5/25/2017
None
ࠓճ͘͠ ηΩϡϦςΟͷͰ ͋Γ·ͤΜ
None
݁
ຊ ୯ҰTZͰ Α͔ͬͨͶ
ຊ DSTඇద༻Ͱ Α͔ͬͨͶ
·͋ ͬͯ UTC͑
None
QiitaʹRailsͷλΠϜκʔϯ ͷΛॻ͖·ͨ͠ ཁͱͯ͠ɺRubyͷTimeͱDateͱDateTimeΦϒδΣΫτੜ ࣌ͷڍಈͱλΠϜκʔϯΛอ࣋͢Δ͔Ͳ͏͔͕ͦΕͧΕඍົʹҧ ͍·͢ɻ
QiitaʹRailsͷλΠϜκʔϯ ͷΛॻ͖·ͨ͠ …͕ɺγεςϜ࣌ࠁ͕JSTʁͦΜͳαʔόʔͰproductionಈ͔͢Θ͚ ͋Γ·ͤΜɻ ʢ΄Μͱʹຊࠃ֎ʹҰग़͢ؾ͕ͳͯ͘ຊࠃ֎ʹҰσʔλ Λserve͢Δؾ͕ͳ͚Εߏ͍·ͤΜ͕ʣ
αʔόͬͯUTC • σʔλϕʔεʹอଘ͢Δɺ • ΫΤϦ͢ΔͨΊʹ͏ɺ • ͯ͢UTCͰ͢ɻ • JSTͷn࣌Ҏલ͕ཉ͚͠ΕΫΤϦʹ͏มΛ௨͢ɻ
ؓٳ: UTCͬͯԿͷུ • ӳޠͰCoordinated Universal Time • Α͋͘Δӳޠ͡Όͳུ͍শ͍͍ͩͨϑϥϯεޠʢFIFAͱ͔ FIBAͱ͔FINAͱ͔͋ΕͶʣͰ͕͢ϑϥϯεޠͰTemps universel
coordonné • ͦͷؒΛऔͬͯUTC
͡Ό͋ ԿͰʁ
Daylight Saving Time
Daylight Saving Timeͱ • ՆʹͳΔͱ࣌ܭΛ1࣌ؒޙΖʹͣΒ͠ • ౙʹͳΔͱ࣌ܭΛ1࣌ؒલʹ͢ ʮՈʹؼͬͨ͋ͱ໌Δ͍͕࣌ؒ͘ͳΔʯΛૂ͍ͬͯΔɻ
None
αϚʔλΠϜࡴਓࣄ݅ ΧϦϑΥϧχΞʢඪ४࣌UTC-8ɺՆ࣌ؒUTC-7ʣɺ11݄ͷୈ1 ༵ʹͯ Aʮඃऀͷࢮਪఆ࣌ࠁ01:30ʯ BʮԶͬͯͳ͍ʂԶ01:30ʹ60ϚΠϧΕͨͱ͜Ζʹ͍ͨ ΜͩʂϨγʔτ͕ΞϦόΠΛূ໌ͯ͘͠ΕΔʂʯ
Կ͕͔ʁ DSTద༻ԼͰlocal timeΛ͏ͱʮಉ࣌͡ࠁ͕2ճͬͯ͘Δʯ͠ ͘ʮͬͯ͜ͳ͍࣌ࠁ͕͋Δʯ ͳͷͰ࣌ࠁ͕࿈ଓͯ͠ଘࡏ͢ΔUTCΛج४ʹมͯ͠Ε͍͍ɻ Aʮඃऀͷࢮਪఆ࣌ࠁUTC08:30Ͱ͓લͷϨγʔτ UTC09:30ͳΜ͕ͩͳ͋ɻͦ͏͍͑ߴಓ࿏ͷ੍ݶ65mph ͚ͩͬʁʯ
͋Δ͕DSTద༻͔Ͳ͏͔ ΛΔʹʁ ࠃʹΑΓDSTద༻ͷϙϦγʔ͕ҟͳΔͷͰࣗ໌ͳͰͳ͍ɻ
͋Δ͕DSTద༻͔Ͳ͏͔ ΛΔʹʁ • ຊͰ͢ΒྖԼͷ1948ʙ1951DSTద༻ͩͬͨ • DSTద༻ͰΒΕΔΞϝϦΧհɻΞϦκφभඇద༻ɺͨ ͩ͠ΞϦκφभʹؚ·ΕΔφόϗɾωΠγϣϯͷҬDSTద ༻ʢΞϝϦΧࠃͩͱଞʹϋϫΠDSTඇద༻ʣ • DSTద༻ࠃؒͰʮԿ݄ͷୈԿͷԿ༵ʹ։࢝ɾऴྃʯ͕ҟͳ
ΔʢΠϥϯݻఆͷͰߦ͏ʣ
†ҋ†Λղܾ͢Δ tz database
tz databaseͱ ผ໊IANA Timezone Database, Olson/Eggert database ͋ΔҬͰλΠϜκʔϯ͕ͲͷΑ͏ͳมԽΛḷ͔ͬͨΛه͢Δ σʔλϕʔεɻ ΤϦΞ໊/Ҭ໊(ྫ:Asia/Tokyo,
America/Los_Angeles)ͱ͍ͬͨදه ͰಛఆͷҬͷ࣌ࠁͷมԽΛτϨʔε͢Δɻ
ྫ 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 offset32400ඵ(+9h)
ྫ 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ͷ19485݄20:00ΑΓՆ࣌ؒద༻ͳͷͰɺUTCͰͷ1948/5/3 0:00Ն࣌ؒద༻ൣғɻJDTͱ͍͏λΠϜκʔϯʂ
ྫ 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͕201711݄5 01:30Λࢦ࣌͢ࠁPST 01:30ͱPDT 01:30ͷ2͕ͭ͋Γ͏Δɻ
ྫ s4 = :calendar.datetime_to_gregorian_seconds({{2017, 3, 12}, {2, 30, 0}}) Tzdata.periods_for_time("America/Los_Angeles",
s4, :wall) # [] wall clock͕20173݄12 02:30Λࢦ͢͜ͱͳ͍
Ξοϓσʔτ͕සൟʹ͋Δ 2016ͷ࠷ऴ2016jɺͭ·Γ2016ͷؒͰ10ճߋ৽͕͋ͬ ͨɻ ϙϦγʔͷมԽ͕10ճ͋ͬͨͷͰͳ͘bugfixͱ͔͋Δɻ ੲͷLinuxͰJapan/South Ryukyu IslandsΛࢦ͢ͱUTC+8ʹͳͬͨͱ ͍͏όά͕͋ͬͨɻ͜ΕtzdataʹʮླྀٿॾౡͰUTC+8͕ΘΕ ͍ͯͨʯͱ͍͏ޡใ͕هࡌ͞Ε͍ͯͨͨΊɻ
Erlang/Elixirͷ࣌ࠁϥΠϒϥ Ϧ͕͠ΜͲ͍ • ErlangElixirͦ͜·Ͱ࣌ࠁม͕ڧ͍Θ͚Ͱͳ͍ • λΠϜκʔϯΛؚΉ࣌ࠁܕElixirʹ͋Δ • Tzdatatz databaseͷAPIΛఏڙ͢ΔͷΈɺ͔͠͠ಉػೳͷ RubyͷϥΠϒϥϦʹൺͯAPI͕গʑ͠ΜͲ͍
• Erlangͷerlang_localtimeAPIΑ͍͕tz databaseߋ৽ͷpull request͕์ஔ͞Ε͍ͯΔ
Erlang/Elixirͷ࣌ࠁϥΠϒϥ Ϧ͕͠ΜͲ͍ • ݱঢ়ͰʮAPI͕͠ΜͲ͘ͳ͍ʯʮself-updating or maintainedʯΛ ຬͨ͢ͷ͓ͦΒ͘Calendar @ ElixirɻElixir 1.3Ͱಋೖ͞Εͨܕ
ʹλΠϜκʔϯมΛఏڙ͢ΔɻͬͱλΠϜκʔϯಋೖʹ Αͬͯएׯͷ͠ΜͲ͞ಋೖ͞Ε͍ͯΔ
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"}}
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"}]}}
Erlang/Elixirͷ࣌ࠁϥΠϒϥ Ϧ͕͠ΜͲ͍ iex(5)> Calendar.DateTime.from_erl {{2017, 3, 12}, {2, 30, 0}},
"America/Los_Angeles" {:error, :invalid_datetime_for_timezone}
Erlang/Elixirͷ࣌ࠁϥΠϒϥ Ϧ͕͠ΜͲ͍ • from_erl/1 ͷҾ͕UTCͰͳͦ͘ͷλΠϜκʔϯʹ͓͚Δ wall clockͰ͋Δ͜ͱ໊͕લ͔ΒΓ͍ͨɻͦΓΌͦ͏ͩͱ͍͑ ͦ͏͚ͩͲ… • %Calendar.AmbiguousDateTime
ʹแ·ΕͯΔͷύλʔϯϚ ονͷͨΊͩΖ͏͚Ͳ… ͱ͍͑ݱঢ়ͰҰ൪Ϛγʹݟ͑Δɻ
None
݁
ຊ ୯ҰTZͰ Α͔ͬͨͶ
ຊ DSTඇద༻Ͱ Α͔ͬͨͶ
·͋ ͬͯ UTC͑
Questions?
More Decks by sylph01
See All by sylph01
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
3
1.8k
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
440
人命を救う技術としてのEnd-to-End暗号化とMessaging Layer Security
sylph01
3
380
Updates on MLS on Ruby (and maybe more)
sylph01
1
330
End-to-End Encryption Saves Lives. You Can Start Saving Lives With Ruby, Too (RubyConf Taiwan 2025 ver.)
sylph01
1
220
PicoRuby's Networking is Incomplete
sylph01
1
360
The Definitive? Guide To Locally Organizing RubyKaigi
sylph01
9
4.4k
End-to-End Encryption Saves Lives. You Can Start Saving Lives With Ruby, Too
sylph01
1
280
End-to-End Encryption Saves Lives. You Can Start Saving Lives With Ruby, Too (JP subtitles)
sylph01
2
1.2k
Other Decks in How-to & DIY
See All in How-to & DIY
RustでもVJしたい!
taiseiue
0
120
ATOMS3R-CAMとClaude SKILLSでタイムラプスチャレンジ #iotlt
n0bisuke2
0
470
キャリア科目では教えてくれない、就活を生き抜く法則
logica0419
2
390
JAWS-UG くまもと #18 KiroによるAI駆動開発
awsjcpm
0
110
How to craft YOUR handmade PicoRuby Instrument
bash0c7
1
110
Rails 8.1.1 × Claude Code
miyakawa2449
1
170
サイボウズには100名以上の社員が出演する"夏フェス"があるって本当?
oguemon
1
1.1k
放っておくと怖い睡眠負債について/fjordbootcamp-251122
yuukago
3
440
JAWS-UG 福岡 KYUSYU QUEST - AWSコミュニティ支援のいまむかし
awsjcpm
0
210
地域コミュニティって いいよね/Local Communities Are Pretty Great
aokiplayer
1
170
Goカードゲームを 作ってみた!
senoue
0
360
ことみんの登壇資料の作り方〜登壇はいいぞ〜
kotomin_m
6
1.2k
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
590
Fireside Chat
paigeccino
43
4.1k
ラッコキーワード サービス紹介資料
rakko
5
6M
Faster Mobile Websites
deanohume
310
32k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.8k
Deep Space Network (abreviated)
tonyrice
0
430
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
61k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.9k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
390