Browse Source

Switched from RFC3339Nano to RFC3339Milli precision

Amir Khan 8 years ago
parent
commit
bd3c6a08e9
2 changed files with 5 additions and 2 deletions
  1. 2 0
      psiphon/common/utils.go
  2. 3 2
      psiphon/notice.go

+ 2 - 0
psiphon/common/utils.go

@@ -35,6 +35,8 @@ import (
 	"time"
 )
 
+const RFC3339Milli = "2006-01-02T15:04:05.999Z07:00"
+
 // Contains is a helper function that returns true
 // if the target string is in the list.
 func Contains(list []string, target string) bool {

+ 3 - 2
psiphon/notice.go

@@ -100,7 +100,7 @@ func outputNotice(noticeType string, noticeFlags uint32, args ...interface{}) {
 	obj["noticeType"] = noticeType
 	obj["showUser"] = (noticeFlags&noticeShowUser != 0)
 	obj["data"] = noticeData
-	obj["timestamp"] = time.Now().UTC().Format(time.RFC3339Nano)
+	obj["timestamp"] = time.Now().UTC().Format(common.RFC3339Milli)
 	for i := 0; i < len(args)-1; i += 2 {
 		name, ok := args[i].(string)
 		value := args[i+1]
@@ -123,7 +123,8 @@ func outputNotice(noticeType string, noticeFlags uint32, args ...interface{}) {
 		obj["data"] = map[string]interface{}{
 			"message": fmt.Sprintf("Marshal notice failed: %s", common.ContextError(err)),
 		}
-		obj["timestamp"] = time.Now().UTC().Format(time.RFC3339Nano)
+
+		obj["timestamp"] = time.Now().UTC().Format(common.RFC3339Milli)
 		encodedJson, err := json.Marshal(obj)
 		if err == nil {
 			output = string(encodedJson)