Skip to content
Browse files

Date.prototype.setFullYear() implementation

  • Loading branch information...
1 parent 447f1a4 commit 333286fc80d8ea95d383e5ba59e74819d2b5cc25 @abstractj abstractj committed Sep 29, 2012
View
6 src/main/java/org/dynjs/runtime/builtins/types/BuiltinDate.java
@@ -227,6 +227,12 @@ public Object call(ExecutionContext context, Object self, Object... args) {
return getDateTime((DynDate) self).toDateTime(DateTimeZone.UTC).getMillis();
}
});
+ defineNonEnumerableProperty(proto, "setFullYear", new AbstractNativeFunction(globalObject) {
+ @Override
+ public Object call(ExecutionContext context, Object self, Object... args) {
+ return getDateTime((DynDate) self).getMillis();
+ }
+ });
}
private DateTime getDateTime(Object self) {
View
5 src/test/java/org/dynjs/runtime/builtins/types/BuiltinDateTest.java
@@ -245,4 +245,9 @@ public void testDateSetMonth() {
public void testDateSetUTCMonth() {
assertThat(eval("new Date().setUTCMonth(9)")).isEqualTo(fixedInstant);
}
+
+ @Test
+ public void testDateSetFullYear() {
+ assertThat(eval("new Date().setFullYear(2012)")).isEqualTo(fixedInstant);
+ }
}

0 comments on commit 333286f

Please sign in to comment.
Something went wrong with that request. Please try again.