APIè¶ãã§ã¿ã¤ã ã¹ã¿ã³ããããã¨ãããæã®ãã©ã¼ããããã©ãããã¹ãã
APIã®ãªã¯ã¨ã¹ãã«ããã¬ã¹ãã³ã¹ã«ãããã¿ã¤ã ã¹ã¿ã³ããå©ç¨ããã¨ããã®ã¯ãããã話ã§ãã
ãã®æããã®ã¿ã¤ã ã¹ã¿ã³ãã®ãã©ã¼ããããã©ãããã®ãè¯ãã®ãã¨ãã話é¡ã§ããIDLã使ã£ã¦ç¸ãã¨ããã¨ããã®ã¯è¯ãèãã ã¨æãã¾ãããIDLã使ãã«ãããã©ã¼ãããã«ã¤ãã¦ã¯æ±ºããªãã¦ã¯ãªããªãã®ã§ã
1. æååã使ã
ããããã¾è¯ããªãã¨æããã§ãããâ¦â¦ã¨ããã®ããã¨ããAPIã触ã£ã¦ããæã«ãã¿ã¤ã ã¹ã¿ã³ãã¯RFC3339ã§ããã¨ãããã£ã¼ã«ãããã£ããã§ãããã©RFC3339ã§ã¯ãªããã©ã¼ãããã§è¿å´ããããåãå
¥ãããããããã®ã§ãã¾ãä¿¡ç¨ãã§ããªãâ¦â¦
ã¾ããã©ã¼ããããä¸æ£ã¨ããã®ã¯æ¥µç«¯ãªä¾ãããããªãã§ãããä»®ã«ãã©ã¼ããããä¸æ£ã ã¨å¤ãã®å ´å strptime()
ã time.Parse()
ãªããã®æå»æååã®parserãæ£ããåãã (è¯ãã±ã¼ã¹ã ã¨ã¨ã©ã¼ãä¸ãããæªãã±ã¼ã¹ã ã¨æ¬æ¥æå³ããªãæå»ã¨ãã¦æ±ããããå¾è
ã大ããªåé¡) ã·ã¹ãã ãå£ããã¨æãã®ã§unix timeã使ã£ãã»ããè¯ãã¨èãã¦ãã¾ãããã¨ãã¾ã ã«strptime/strftimeã®å¤ææå®ãæºè¶³ã«è¦ããããªãï¼
ãã¨ã¿ã¤ã ã¹ã¿ã³ãæååã ã¨ç¡éªæ°ã«ã¿ã¤ã ã¾ã¼ã³æ å ±ãæ¬ è½ãã¦ãããããã¨ããããã§ããããunix timeã使ã£ãã»ããè¯ãã¨èããä¸å ã§ããã¾ãã¡ããã¨ã¿ã¤ã ã¾ã¼ã³æ å ±ãä»ãã¦ãããã°è¯ããã§ããã©ã
ã°ãã¼ãã«ç¤¾ä¼ã«ãªã£ã¦ä¹ ããä¸æ¹ã§ç¡éªæ°ã«ã¿ã¤ã ã¾ã¼ã³ãçããã¿ã¤ã ã¹ã¿ã³ãæååãAPIè¶ãã«é£ãã§ãã¦ä¿ºã®é ã¯ççºå¯¸åã â¦â¦
— moznion (@moznion) 2021å¹´12æ9æ¥
å¥è§£
ã¿ã¤ã ã¹ã¿ã³ãæååã¨ä¸ç·ã«strftimeã«é£ããããã¨ãã§ãããã©ã¼ãããæååãéã£ã¦ãã¦ãããã°è§£æ±ºï¼
— Daisuke Maki (@lestrrat) 2021å¹´12æ9æ¥
ããã
2. unix timeã使ã
ã¾ããããç©å½ãªããããªãã§ããããUTCã§ãããã¨ãæ確ã ãâ¦â¦ã¨æããããããã£ãè½ãç©´ãã
精度ã¯ç§ã®æ´æ°ããmillisecåä½ã®æ´æ°(ç§ã®1000å)ããsubsecãå ¥ã£ãæµ®åå°æ°ç¹ã®ã©ã¡ããããããã§ããããâ¦
— fujiwara (@fujiwara) 2021å¹´12æ9æ¥
ããã«ã¤ãã¦ã¯2ã¤ããã¨æã£ã¦ãã¦ãæéã®è§£å度 (åä½) ã«ã¤ãã¦ã¯ãã£ã¼ã«ãã« _sec
ã¨ã _ms
ã®ãããªæ¥å°¾è¾ãä»ãããã¨ã§æ確ã«ããããã«å¿ããã¦ãã¾ããæ¬è³ªçã«ãã¹ãé²ãããã¨ããã¨æªããã§ãããç¡ãããã¯è¯ãã§ããããã¨ããèãã§ãã
unixtimeè¿ãããåãããããAPIãæè¿ã¯ãã©ã¡ã¼ã¿åã«åä½ä»ããããã«å¿æãã¦ãã¾ãã`received_time_epoch_sec` ã¨ã `created_time_epoch_ms` ã¨ãâ¦â¦åé·ã ãã©ã
— moznion (@moznion) 2021å¹´12æ9æ¥
ããä¸ã¤ã®ãæ´æ°ãå°æ°ããã«ã¤ãã¦ã¯åã¨ãã¦ç¸ãã¨ããã®ãæ¹æ³ãããªãã§ããããâ¦â¦IDLã§ããã®ãè¯ãã®ã§ããããã
3. TAI64ã使ã
https://cr.yp.to/libtai/tai64.html
ãã£ããä¸æãªãã©ã¼ãããã ï¼ï¼ï¼
ã¨ã¯ãã人éãåºæ¬çã«ã¯èªããªãããããç§ã®æ±ããç¹æ®ããªã©è²ã
ããããã¯ããã§å°ãããã§ããã
ãã£ã±tai64nããæãã¯ãªããªãdjbãä¿¡ãã
— moznion (@moznion) 2021å¹´12æ9æ¥
æããã¦ããã ãããï¼
ç¾æç¹ã§ã®å人çãªè¦è§£
- unix timeã使ã
- å解è½ã¯ä½ããã®æ¹æ³ã§æ示ãã
- IDLã使ã
ã¨ããããããç¾å®çãªè½ãã©ãããããªãã§ãããããä»ã«ãªã«ããAPIã®ãªã¯ã¨ã¹ãã»ã¬ã¹ãã³ã¹ã«ä½¿ããããªå éçãªæé表ç¾ã£ã¦ãããã§ããããï¼
[追è¨]
unix timeã ã¨çµå±ã¿ã¤ã ã¾ã¼ã³ãå¥ééãã¹ãã£ã¦è©±ã«ãªãã¾ããï¼
— FUJI Goro (@__gfx__) 2022å¹´1æ11æ¥
ã¤ã¾ããããã¢ã¯ã·ã§ã³ãè¡ãããã¨ããããããã¼ã«ã«ã¿ã¤ã ã®æãªã®ãå¤ãªã®ãã¯ãã¼ã±çã«ã¯éè¦ãªæ å ±ã ã£ããããããã§ã
ããã£ã¦ããã®APIãcallããã¦ã¼ã¶ã¼ã®å±æ§æ å ± (ã©ãã«ä½ãã§ããã) ã§çªãåããããã¨ãã§ãã¾ããããï¼ããããã¯GEO IPã¨ãâ¦â¦ãã¡ãã¡TZæ å ±å«ãã§éã£ã¦ãã¦ãããã®ã¯å¤§å¤ãªæããã
— moznion (@moznion) 2022å¹´1æ11æ¥
åæãã¼ã ãããã¤ãºããã£ã¦ããããã¨ããã®ã«äºæ¿ãã¦ãããã®ã§ããã°ããã§ããããããªãã§ããã
— FUJI Goro (@__gfx__) 2022å¹´1æ11æ¥
ãã ããã¤ãºãå«ã¾ãã¦ãã確çã¯ä¸æã§ããâ¦ã
APIã®ç¹æ§ã«ä¾ãã¨æã£ã¦ãã¦ãTZãå¿ è¦ãªãã®ã§ããã°ä»ãããã¨ããã®ã¯åæã§ãããã©ã¦ã¶ã使ã£ã¦ãããããªãã®ã ã£ããTZåãã®ãé£ãããªãã§ããããã
— moznion (@moznion) 2022å¹´1æ11æ¥
ä¸æ¹ã§ããããã®ãå¿ è¦ãªãAPIãããã¨æã£ã¦ãã¦ãåãããæ±ãã®ã¯ããããAPIã ã£ãã¨ãã話ã ã¨æãã¾ãã
ããã¯å ¨ããã®ã¨ããã§ããä¸æ¹ã§ãã°ã¯åãç´ãã§ããªãã®ã§ããæéã«ã¯æèåæ¢ã§timezoneæ å ±ã¯ã¤ãã¦ãããã¨ãæãã¾ãã
— FUJI Goro (@__gfx__) 2022å¹´1æ11æ¥
ãããã³ã«ãããã¡ã¼ã£ã¦ãã大統ä¸ã·ãªã¢ã©ã¤ã¼ã¼ã·ã§ã³ãã©ã¼ãããã«èº«ãä»»ãã¦ãå ¬å¼ã«åºãã¦ããTimestampãã¿ã¤ã ã¾ã¼ã³ãå¿ è¦ãªãCivil Timestampã使ãã£ã¦ãã¤ãããã¾ããâ¦â¦ https://t.co/V6ylWGxffS
— ï¾ï½ºã¸ã®æ 度ãæãæ¹ãã (@draftcode) 2022å¹´1æ11æ¥
ã¡ãªã¿ã«UNIX timeã§doubleã®åãã¤ãã¦ããã°ãããããã¯"UNIX time"ã¯å®ç¾©ä¸secåä½ã§ããã¨ããæ´¾é¥ã«ä¹ã£åãã¤ã¤ãããããç´°ãã精度ã¯å°æ°ã§ç¤ºãã¨ãããã¨ãªãã ãªãã¨ãããã¨ã人é¡ã®å¿åº¦è½åãæã£ã¦ããã°å¯ããªãã§ãããã
— ï¾ï½ºã¸ã®æ 度ãæãæ¹ãã (@draftcode) 2022å¹´1æ11æ¥
[追è¨ããã¾ã§]