Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP: RFC3339形式だとGoのベンチマーカーがそのままtime.Timeにデコードできて嬉しい #70

Closed
edvakf opened this issue Sep 27, 2016 · 1 comment

Comments

@edvakf
Copy link
Contributor

edvakf commented Sep 27, 2016

別のブランチで作業してるのでとりあえずパッチだけペタリ。

diff --git a/webapp/php/html/index.php b/webapp/php/html/index.php
index 2a45ae1..bd7522b 100644
--- a/webapp/php/html/index.php
+++ b/webapp/php/html/index.php
@@ -47,7 +47,7 @@ function typeCastPointData($data) {
     ];
 }

-const ISO8601MICROSENDS = "Y-m-d\TH:i:s.uO";
+const RFC3339MICROSENDS = "Y-m-d\TH:i:s.uP";

 function typeCastStrokeData($data) {
     return [
@@ -59,7 +59,7 @@ function typeCastStrokeData($data) {
         'blue' => (int)$data['blue'],
         'alpha' => (float)$data['alpha'],
         'points' => isset($data['points']) ? array_map('typeCastPointData', $data['points']) : [],
-        'created_at' => isset($data['created_at']) ? date_create($data['created_at'])->format(ISO8601MICROSENDS) : '',
+        'created_at' => isset($data['created_at']) ? date_create($data['created_at'])->format(RFC3339MICROSENDS) : '',
     ];
 }

@@ -69,7 +69,7 @@ function typeCastRoomData($data) {
         'name' => $data['name'],
         'canvas_width' => (int)$data['canvas_width'],
         'canvas_height' => (int)$data['canvas_height'],
-        'created_at' => isset($data['created_at']) ? date_create($data['created_at'])->format(ISO8601MICROSENDS) : '',
+        'created_at' => isset($data['created_at']) ? date_create($data['created_at'])->format(RFC3339MICROSENDS) : '',
         'strokes' => isset($data['strokes']) ? array_map('typeCastStrokeData', $data['strokes']) : [],
         'stroke_count' => (int)$data['stroke_count'],
         'watcher_count' => (int)$data['watcher_count'],
@catatsuy
Copy link
Member

Go実装はこちらになっているんですね

@edvakf edvakf closed this as completed in 362a8ce Oct 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants