Ver Fonte

Changed toUTCString() format. Closes #119.

Dmitry Panov há 5 anos atrás
pai
commit
aaec0e7bde
3 ficheiros alterados com 3 adições e 2 exclusões
  1. 1 1
      builtin_date.go
  2. 1 0
      date.go
  3. 1 1
      date_test.go

+ 1 - 1
builtin_date.go

@@ -152,7 +152,7 @@ func (r *Runtime) dateproto_toUTCString(call FunctionCall) Value {
 	obj := r.toObject(call.This)
 	if d, ok := obj.self.(*dateObject); ok {
 		if d.isSet {
-			return asciiString(d.time.In(time.UTC).Format(dateTimeLayout))
+			return asciiString(d.time.In(time.UTC).Format(utcDateTimeLayout))
 		} else {
 			return stringInvalidDate
 		}

+ 1 - 0
date.go

@@ -6,6 +6,7 @@ import (
 
 const (
 	dateTimeLayout       = "Mon Jan 02 2006 15:04:05 GMT-0700 (MST)"
+	utcDateTimeLayout    = "Mon, 02 Jan 2006 15:04:05 GMT"
 	isoDateTimeLayout    = "2006-01-02T15:04:05.000Z"
 	dateLayout           = "Mon Jan 02 2006"
 	timeLayout           = "15:04:05 GMT-0700 (MST)"

+ 1 - 1
date_test.go

@@ -95,7 +95,7 @@ func TestNewDate0(t *testing.T) {
 	(new Date(0)).toUTCString();
 
 	`
-	testScript1(SCRIPT, asciiString("Thu Jan 01 1970 00:00:00 GMT+0000 (UTC)"), t)
+	testScript1(SCRIPT, asciiString("Thu, 01 Jan 1970 00:00:00 GMT"), t)
 }
 
 func TestSetHour(t *testing.T) {