summaryrefslogtreecommitdiff
path: root/services/jsondate.esp
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2006-10-06 15:50:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:20:42 -0500
commit250399c9230ea972f6bf374fb9951b6cb35320f2 (patch)
tree153429c2707deb90857c1ad258b96449ddd67af2 /services/jsondate.esp
parent10c06a1968dbf39d8a3790077a3537b8323f36ff (diff)
downloadsamba-250399c9230ea972f6bf374fb9951b6cb35320f2.tar.gz
samba-250399c9230ea972f6bf374fb9951b6cb35320f2.tar.bz2
samba-250399c9230ea972f6bf374fb9951b6cb35320f2.zip
r19142: ensure no race conditions during installation by having same name in source and swat directory; install new apps and services
(This used to be commit a2b996317f81aa61d7d5bf427003399560e64f77)
Diffstat (limited to 'services/jsondate.esp')
-rw-r--r--services/jsondate.esp200
1 files changed, 200 insertions, 0 deletions
diff --git a/services/jsondate.esp b/services/jsondate.esp
new file mode 100644
index 0000000000..3467228df6
--- /dev/null
+++ b/services/jsondate.esp
@@ -0,0 +1,200 @@
+<%
+/*
+ * Copyright:
+ * (C) 2006 by Derrell Lipman
+ * All rights reserved
+ *
+ * License:
+ * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
+ */
+
+/*
+ * Date class for JSON-RPC
+ */
+
+
+function _JSON_Date_create(secondsSinceEpoch)
+{
+ var o = new Object();
+ o.__type = "_JSON_Date";
+
+ function _setUtcDateTimeFields(year, month, day, hour, minute, second, millisecond)
+ {
+ this.year = year + 0;
+ this.month = month + 0;
+ this.day = day + 0;
+ this.hour = hour + 0;
+ this.minute = minute + 0;
+ this.second = second + 0;
+ this.millisecond = millisecond + 0;
+ }
+
+ o.setUtcYear = _setUtcDateTimeFields;
+
+ function _setUtcYear(year)
+ {
+ this.year = year + 0;
+ }
+ o.setUtcYear = _setUtcYear;
+
+ function _setUtcMonth(month)
+ {
+ this.month = month + 0;
+ }
+ o.setUtcMonth = _setUtcMonth;
+
+ function _setUtcDay(day)
+ {
+ this.day = day + 0;
+ }
+ o.setUtcDay = _setUtcDay;
+
+ function _setUtcHour(hour)
+ {
+ this.hour = hour + 0;
+ }
+ o.setUtcHour = _setUtcHour;
+
+ function _setUtcMinute(minute)
+ {
+ this.minute = minute + 0;
+ }
+ o.setUtcMinute = _setUtcMinute;
+
+ function _setUtcSecond(second)
+ {
+ this.second = second + 0;
+ }
+ o.setUtcSecond = _setUtcSecond;
+
+ function _setUtcMillisecond(millisecond)
+ {
+ this.millisecond = millisecond + 0;
+ }
+ o.setUtcMillisecond = _setUtcMillisecond;
+
+ function _setEpochTime(secondsSinceEpoch)
+ {
+ var microseconds = 0;
+
+ if (typeof(secondsSinceEpoch) != "number")
+ {
+ var currentTime = gettimeofday();
+ secondsSinceEpoch = currentTime.sec;
+ microseconds = currentTime.usec;
+ }
+
+ var tm = gmtime(secondsSinceEpoch);
+
+ this.year = 1900 + tm.tm_year;
+ this.month = tm.tm_mon;
+ this.day = tm.tm_mday;
+ this.hour = tm.tm_hour;
+ this.minute = tm.tm_min;
+ this.second = tm.tm_sec;
+ this.millisecond = 0;
+ }
+ o.setEpochTime = _setEpochTime;
+
+ function _getUtcYear()
+ {
+ return this.year;
+ }
+ o.getUtcYear = _getUtcYear;
+
+ function _getUtcMonth()
+ {
+ return this.month;
+ }
+ o.getUtcMonth = _getUtcMonth;
+
+ function _getUtcDay()
+ {
+ return this.day;
+ }
+ o.getUtcDay = _getUtcDay;
+
+ function _getUtcHour()
+ {
+ return this.hour;
+ }
+ o.getUtcHour = _getUtcHour;
+
+ function _getUtcMinute()
+ {
+ return this.minute;
+ }
+ o.getUtcMinute = _getUtcMinute;
+
+ function _getUtcSecond()
+ {
+ return this.second;
+ }
+ o.getUtcSecond = _getUtcSecond;
+
+ function _getUtcMillisecond()
+ {
+ return this.millisecond;
+ }
+ o.getUtcMillisecond = _getUtcMillisecond;
+
+ function _getEpochTime()
+ {
+ var tm = new Object();
+ tm.tm_sec = this.second;
+ tm.tm_min = this.minute;
+ tm.tm_hour = this.hour;
+ tm.tm_mday = -1;
+ tm.tm_mon = this.month;
+ tm.tm_year = this.year;
+ tm.tm_wday = -1;
+ tm.tm_yday = -1;
+ tm.isdst = 0;
+ return gmmktime(tm);
+ }
+ o.getEpochTime = _getEpochTime;
+
+ function _encoding()
+ {
+ /* Encode the date in a well-documented fashion */
+ return sprintf("new Date(Date.UTC(%d,%d,%d,%d,%d,%d,%d))",
+ this.year,
+ this.month,
+ this.day,
+ this.hour,
+ this.minute,
+ this.second,
+ this.millisecond);
+ }
+ o.encoding = _encoding;
+
+ if (! secondsSinceEpoch)
+ {
+ var now = gettimeofday();
+ o.setEpochTime(now.sec);
+ }
+ else
+ {
+ o.setEpochTime(secondsSinceEpoch);
+ }
+ o.year = 0;
+ o.month = 0;
+ o.day = 0;
+ o.hour = 0;
+ o.minute = 0;
+ o.second = 0;
+ o.millisecond = 0;
+ return o;
+}
+
+JSON_Date = new Object();
+JSON_Date.create = _JSON_Date_create;
+_JSON_Date_create = null;
+
+
+/*
+ * Local Variables:
+ * mode: c
+ * End:
+ */
+%>