[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/asobj/Date.cpp testsuite...
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] gnash ChangeLog server/asobj/Date.cpp testsuite... |
Date: |
Mon, 07 Apr 2008 09:22:10 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Benjamin Wolsey <bwy> 08/04/07 09:22:10
Modified files:
. : ChangeLog
server/asobj : Date.cpp
testsuite/actionscript.all: Date.as
Log message:
* server/asobj/Date.cpp: add getUTCYear(), fix setMilliseconds,
fix setFullYear.
* testsuite/actionscript.all/Date.as: drop tests that vary
according
to local timezone. Add tests for getUTCYear, more passes for
milliseconds and full year.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6196&r2=1.6197
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Date.cpp?cvsroot=gnash&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Date.as?cvsroot=gnash&r1=1.49&r2=1.50
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6196
retrieving revision 1.6197
diff -u -b -r1.6196 -r1.6197
--- ChangeLog 7 Apr 2008 09:19:00 -0000 1.6196
+++ ChangeLog 7 Apr 2008 09:22:09 -0000 1.6197
@@ -1,3 +1,11 @@
+2008-04-07 Benjamin Wolsey <address@hidden>
+
+ * server/asobj/Date.cpp: add getUTCYear(), fix setMilliseconds,
+ fix setFullYear.
+ * testsuite/actionscript.all/Date.as: drop tests that vary according
+ to local timezone. Add tests for getUTCYear, more passes for
+ milliseconds and full year.
+
2008-04-07 Sandro Santilli <address@hidden>
* testsuite/actionscript.all/Object.as: test that native
Index: server/asobj/Date.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Date.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- server/asobj/Date.cpp 6 Apr 2008 17:48:31 -0000 1.61
+++ server/asobj/Date.cpp 7 Apr 2008 09:22:10 -0000 1.62
@@ -166,6 +166,7 @@
static as_value date_getseconds(const fn_call& fn);
static as_value date_getmilliseconds(const fn_call& fn);
static as_value date_getutcfullyear(const fn_call& fn);
+static as_value date_getutcyear(const fn_call& fn);
static as_value date_getutcmonth(const fn_call& fn);
static as_value date_getutcdate(const fn_call& fn);
static as_value date_getutcday(const fn_call& fn);
@@ -175,6 +176,8 @@
static as_value date_setfullyear(const fn_call& fn);
static as_value date_sethours(const fn_call& fn);
static as_value date_setmilliseconds(const fn_call& fn);
+static as_value date_setutcseconds(const fn_call& fn);
+static as_value date_setutcmilliseconds(const fn_call& fn);
static as_value date_setminutes(const fn_call& fn);
static as_value date_setmonth(const fn_call& fn);
static as_value date_setseconds(const fn_call& fn);
@@ -194,6 +197,10 @@
static void attachDateInterface(as_object& o);
static void attachDateStaticInterface(as_object& o);
+// As UTC offset is measured in minutes, we can use the same
+// functions to get seconds and milliseconds in local and utc time.
+// But setting either of them can have a knock-on effect on minutes
+// and hours, so both need their own set functions.
static void
attachDateInterface(as_object& o)
{
@@ -210,6 +217,7 @@
o.init_member("getUTCDate", new builtin_function(date_getutcdate));
o.init_member("getUTCDay", new builtin_function(date_getutcday));
o.init_member("getUTCFullYear", new builtin_function(date_getutcfullyear));
+ o.init_member("getUTCYear", new builtin_function(date_getutcyear));
o.init_member("getUTCHours", new builtin_function(date_getutchours));
o.init_member("getUTCMilliseconds", new
builtin_function(date_getmilliseconds)); // same
o.init_member("getUTCMinutes", new builtin_function(date_getutcminutes));
@@ -227,10 +235,10 @@
o.init_member("setUTCDate", new builtin_function(date_setutcdate));
o.init_member("setUTCFullYear", new builtin_function(date_setutcfullyear));
o.init_member("setUTCHours", new builtin_function(date_setutchours));
- o.init_member("setUTCMilliseconds", new
builtin_function(date_setmilliseconds)); // same
+ o.init_member("setUTCMilliseconds", new
builtin_function(date_setutcmilliseconds));
o.init_member("setUTCMinutes", new builtin_function(date_setutcminutes));
o.init_member("setUTCMonth", new builtin_function(date_setutcmonth));
- o.init_member("setUTCSeconds", new builtin_function(date_setseconds));
+ o.init_member("setUTCSeconds", new builtin_function(date_setutcseconds));
o.init_member("setYear", new builtin_function(date_setyear));
o.init_member("toString", new builtin_function(date_tostring));
o.init_member("valueOf", new builtin_function(date_valueof));
@@ -375,9 +383,10 @@
int year = static_cast<int>(fn.arg(0).to_number());
// GnashTime.year is the value since 1900 (like struct tm)
- // negative value is a year before 1900
- // A year between 0 and 99 is the year since 1900
+ // negative value is a year before 1900. A year between 0
+ // and 99 is the year since 1900 (which is the same arithmetic).
if (year < 100) gt.year = year;
+
// A value of 100 or more is a full year and must be
// converted to years since 1900
else gt.year = year - 1900;
@@ -492,6 +501,7 @@
// The same functions for universal time.
//
date_get_proto(date_getutcfullyear, getUniversalTime, year + 1900)
+date_get_proto(date_getutcyear, getUniversalTime, year)
date_get_proto(date_getutcmonth, getUniversalTime, month)
date_get_proto(date_getutcdate, getUniversalTime, monthday)
date_get_proto(date_getutcday, getUniversalTime, weekday)
@@ -690,10 +700,7 @@
GnashTime gt;
dateToGnashTime(*date, gt, false);
- gt.year = (int) fn.arg(0).to_number();
- // tm_year is number of years since 1900, so if they gave a
- // full year spec, we must adjust it.
- if (gt.year >= 100) gt.year -= 1900;
+ gt.year = static_cast<int>(fn.arg(0).to_number()) - 1900;
if (fn.nargs >= 2) gt.month = fn.arg(1).to_int();
if (fn.nargs >= 3) gt.monthday = fn.arg(2).to_int();
@@ -930,7 +937,7 @@
}
static as_value
-date_setmilliseconds(const fn_call& fn)
+_date_setmilliseconds(const fn_call& fn, bool utc)
{
boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
@@ -945,13 +952,22 @@
date->value = NAN;
}
else {
- // Zero the milliseconds and set them from the argument.
- date->value = date->value - std::fmod(date->value, 1000.0) +
fn.arg(0).to_int();
+
+ GnashTime gt;
+
+ dateToGnashTime(*date, gt, utc);
+ gt.millisecond = static_cast<int>(fn.arg(0).to_number());
+
if (fn.nargs > 1) {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Date.setMilliseconds was called with more than
one argument"));
)
}
+
+ // This is both setMilliseconds and setUTCMilliseconds.
+ // Use utc to avoid needless worrying about timezones.
+ gnashTimeToDate(gt, *date, utc);
+
}
return as_value(date->value);
}
@@ -968,6 +984,7 @@
local_proto(hours)
local_proto(minutes)
local_proto(seconds)
+local_proto(milliseconds)
#undef local_proto
// The same things for UTC.
@@ -981,6 +998,8 @@
utc_proto(date)
utc_proto(hours)
utc_proto(minutes)
+utc_proto(seconds)
+utc_proto(milliseconds)
#undef utc_proto
Index: testsuite/actionscript.all/Date.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Date.as,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- testsuite/actionscript.all/Date.as 5 Apr 2008 11:08:19 -0000 1.49
+++ testsuite/actionscript.all/Date.as 7 Apr 2008 09:22:10 -0000 1.50
@@ -22,7 +22,7 @@
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: Date.as,v 1.49 2008/04/05 11:08:19 bwy Exp $";
+rcsid="$Id: Date.as,v 1.50 2008/04/07 09:22:10 bwy Exp $";
#include "check.as"
check_equals(typeof(Date), 'function');
@@ -103,6 +103,7 @@
check (d.getUTCDate);
check (d.getUTCDay);
check (d.getUTCFullYear);
+check (d.getUTCYear);
check (d.getUTCHours);
check (d.getUTCMilliseconds);
check (d.getUTCMinutes);
@@ -146,6 +147,7 @@
check_equals (d.getUTCdate, undefined);
check_equals (d.getUTCday, undefined);
check_equals (d.getUTCfullYear, undefined);
+check_equals (d.getUTCyear, undefined);
check_equals (d.getUTChours, undefined);
check_equals (d.getUTCmilliseconds, undefined);
check_equals (d.getUTCminutes, undefined);
@@ -184,6 +186,7 @@
check (d.getUTCdate);
check (d.getUTCday);
check (d.getUTCfullYear);
+check (d.getUTCyear);
check (d.getUTChours);
check (d.getUTCmilliseconds);
check (d.getUTCminutes);
@@ -515,46 +518,35 @@
check_equals(wierddate.getSeconds(), 12);
check_equals(wierddate.getMilliseconds(), 7);
- xcheck_equals(wierddate.valueOf().toString(), "-65309372987993");
+ // Bogus tests: depend on the timezone.
+ //xcheck_equals(wierddate.valueOf().toString(), "-65309372987993");
wierddate.setMilliseconds(300);
check_equals(wierddate.getMilliseconds(), 300);
- xcheck_equals(wierddate.getSeconds(), 12);
+ check_equals(wierddate.getSeconds(), 12);
- xcheck_equals(wierddate.valueOf().toString(), "-65309372987700");
+ //xcheck_equals(wierddate.valueOf().toString(), "-65309372987700");
wierddate.setMilliseconds(-300);
check_equals(wierddate.getMilliseconds(), 700);
- xcheck_equals(wierddate.getSeconds(), 11);
+ check_equals(wierddate.getSeconds(), 11);
- xcheck_equals(wierddate.valueOf().toString(), "-65309372988300");
+ //xcheck_equals(wierddate.valueOf().toString(), "-65309372988300");
wierddate.setYear(100000);
check_equals(wierddate.getMilliseconds(), 700);
check_equals(wierddate.getFullYear(), 100000);
-#if OUTPUT_VERSION < 8
- xcheck_equals(wierddate.valueOf().toString(), "3.0935415006117e+15");
-#else
- xcheck_equals(wierddate.valueOf().toString(), "3.0935415870117e+15");
-#endif
wierddate.setYear(-100000);
check_equals(wierddate.getMilliseconds(), 700);
- xcheck_equals(wierddate.getFullYear(), -100000);
-#if OUTPUT_VERSION < 8
- xcheck_equals(wierddate.valueOf().toString(), "-3.2178488993883e+15");
-#else
- xcheck_equals(wierddate.valueOf().toString(), "-3.2178488129883e+15");
-#endif
+ check_equals(wierddate.getFullYear(), -100000);
h = new Date(3.0935415006117e+23);
- check_equals(h.getMilliseconds(), 584);
- check_equals(h.getSeconds(), 0);
- check_equals(h.getMinutes(), 4);
- check_equals(h.getDay(), 2);
- xcheck_equals(h.getFullYear(), -2147481678);
- xcheck_equals(h.toString(), "Tue Jan -2147483647 16:04:00 GMT+0000
-2147481678");
+ check_equals(h.getUTCMilliseconds(), 584);
+ check_equals(h.getUTCSeconds(), 0);
+ check_equals(h.getUTCMinutes(), 4);
+ check_equals(h.getUTCDay(), 2);
// It's hard to test TimezoneOffset because the values will be different
// depending upon where geographically you run the tests.
@@ -664,7 +656,7 @@
#endif
#if OUTPUT_VERSION == 5
-totals(290);
+totals(285);
#else
-totals (332);
+totals (327);
#endif