summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-30 19:11:11 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-30 19:11:11 +0200
commita77308735f50fb1735bca82ffd0ffaf12a5c9f62 (patch)
treeabc268c77f5a1938a65ee533b1da6b7d6393ee73 /js
parentc4aadf04aa9c089c6251478f23e941bfa03b3cad (diff)
downloadUXP-a77308735f50fb1735bca82ffd0ffaf12a5c9f62.tar
UXP-a77308735f50fb1735bca82ffd0ffaf12a5c9f62.tar.gz
UXP-a77308735f50fb1735bca82ffd0ffaf12a5c9f62.tar.lz
UXP-a77308735f50fb1735bca82ffd0ffaf12a5c9f62.tar.xz
UXP-a77308735f50fb1735bca82ffd0ffaf12a5c9f62.zip
Bug 1310078 - Implement valueAsNumber and valueAsDate for <input type=datetime-local>
Diffstat (limited to 'js')
-rw-r--r--js/public/Date.h8
-rwxr-xr-xjs/src/jsdate.cpp12
2 files changed, 20 insertions, 0 deletions
diff --git a/js/public/Date.h b/js/public/Date.h
index cba0ea875..cab36a3de 100644
--- a/js/public/Date.h
+++ b/js/public/Date.h
@@ -134,6 +134,14 @@ NewDateObject(JSContext* cx, ClippedTime time);
JS_PUBLIC_API(double)
MakeDate(double year, unsigned month, unsigned day);
+// Year is a year, month is 0-11, day is 1-based, and time is in milliseconds.
+// The return value is a number of milliseconds since the epoch.
+//
+// Consistent with the MakeDate algorithm defined in ECMAScript, this value is
+// *not* clipped! Use JS::TimeClip if you need a clipped date.
+JS_PUBLIC_API(double)
+MakeDate(double year, unsigned month, unsigned day, double time);
+
// Takes an integer number of milliseconds since the epoch and returns the
// year. Can return NaN, and will do so if NaN is passed in.
JS_PUBLIC_API(double)
diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp
index ccaeda2a3..00a8abf84 100755
--- a/js/src/jsdate.cpp
+++ b/js/src/jsdate.cpp
@@ -354,10 +354,22 @@ MakeDate(double day, double time)
JS_PUBLIC_API(double)
JS::MakeDate(double year, unsigned month, unsigned day)
{
+ MOZ_ASSERT(month <= 11);
+ MOZ_ASSERT(day >= 1 && day <= 31);
+
return ::MakeDate(MakeDay(year, month, day), 0);
}
JS_PUBLIC_API(double)
+JS::MakeDate(double year, unsigned month, unsigned day, double time)
+{
+ MOZ_ASSERT(month <= 11);
+ MOZ_ASSERT(day >= 1 && day <= 31);
+
+ return ::MakeDate(MakeDay(year, month, day), time);
+}
+
+JS_PUBLIC_API(double)
JS::YearFromTime(double time)
{
return ::YearFromTime(time);