Explorar o código

update(utc): 优化对 UTC Time 的序列化 review by melon

gavin.chen %!s(int64=2) %!d(string=hai) anos
pai
achega
f8c5964135
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      lib/utils.dart

+ 8 - 1
lib/utils.dart

@@ -2,5 +2,12 @@ import 'package:fis_common/extensions/date.dart';
 
 class JsonRpcUtils {
   static const String _datetimeFormat = "yyyy-MM-ddTHH:mm:ss.SSS";
-  static String dateFormat(DateTime date) => date.format(_datetimeFormat);
+  static const String _utcDateTimeFormat = "yyyy-MM-ddTHH:mm:ss.SSS'Z'";
+  static String dateFormat(DateTime date) {
+    if (date.isUtc) {
+      return date.format(_utcDateTimeFormat);
+    } else {
+      return date.format(_datetimeFormat);
+    }
+  }
 }