Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
タイムゾーンの†闇†
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
More Decks by sylph01
See All by sylph01
人命を救う技術としてのEnd-to-End暗号化とMessaging Layer Security
sylph01
3
220
Updates on MLS on Ruby (and maybe more)
sylph01
1
280
End-to-End Encryption Saves Lives. You Can Start Saving Lives With Ruby, Too (RubyConf Taiwan 2025 ver.)
sylph01
1
160
PicoRuby's Networking is Incomplete
sylph01
1
260
The Definitive? Guide To Locally Organizing RubyKaigi
sylph01
9
3.8k
End-to-End Encryption Saves Lives. You Can Start Saving Lives With Ruby, Too
sylph01
1
210
End-to-End Encryption Saves Lives. You Can Start Saving Lives With Ruby, Too (JP subtitles)
sylph01
2
950
Introduction to C Extensions
sylph01
3
290
"Actual" Security in Microcontroller Ruby!?
sylph01
0
240
Other Decks in How-to & DIY
See All in How-to & DIY
【ふりかえりワークショップ】Tryを決めるだけじゃない!感情にフォーカスした、ふりかえりを体験しよう!
scrummasudar
0
1.3k
10分de名コミュ “最高の自分”を演じ憧れの同業者と渡り合う
subroh0508
1
660
EXPO 2025 大屋根リングをぐるっと周回! 【GPSマルチユニット×ソラカメ実験】
scbc1167
0
130
Node-REDでセンサーなどから起動させるカメラノードを作ったよ IoTLT vol123 #iotlt
n0bisuke2
0
150
MustをWillに変える技術 〜アイドル・郁田はるきが"すべき"の壁を超えるまで〜
subroh0508
1
1.9k
Azure PortalのQoLを上げてたら Big Techに怒られた
horihiro
2
600
How to make the Groovebox
asonas
2
2.2k
AWS Community Builders Update - JAWS-UG Tokyo and Sainokuni
awsjcpm
3
270
社会人9年目の僕が贈る処世術
coco_se
1
220
生成AIは 『コードを書く』だけじゃない アーキテクチャ設計から環境構築まで——社内データ活用DXの全貌
punipuni_mint
0
190
Nutanix Community Edition 超入門 25.04
ricefield66
0
390
「変えること」「変わること」を楽しむ力で"敵わない存在"と向き合う
subroh0508
2
1.6k
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Evolving SEO for Evolving Search Engines
ryanjones
0
220
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
610
Side Projects
sachag
455
43k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.1k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
250
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Automating Front-end Workflow
addyosmani
1370
210k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
It's Worth the Effort
3n
188
29k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
310
Transcript
λΠϜκʔϯͷ†ҋ† 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?