Commit cce22cdb authored by Alain Takoudjou's avatar Alain Takoudjou

[erp5_web_monitoring] fix date timezone when UTC ofset is not set

parent 842587d7
......@@ -33,10 +33,10 @@
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": new Date(result.data.rows[i].value.status_date).toUTCString(),
"default": result.data.rows[i].value.status_date,
key: "date",
required: 0,
timezone_style: 0,
timezone_style: 1,
title: "Status Date",
type: "DateTimeField"
}
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.13495.30840.12936</string> </value>
<value> <string>971.33408.64727.5632</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1541763899.25</float>
<float>1542965869.33</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.40812.22256.57156</string> </value>
<value> <string>971.43798.57526.26624</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1542208228.67</float>
<float>1542387970.17</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -16,7 +16,6 @@
var i, value, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("date")) {
value = new Date(result.data.rows[i].value.date);
result.data.rows[i].value.date = {
field_gadget_param: {
allow_empty_time: 0,
......@@ -27,10 +26,10 @@
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": value.toUTCString(),
"default": result.data.rows[i].value.date,
key: "date",
required: 0,
timezone_style: 0,
timezone_style: 1,
title: "Status Date",
type: "DateTimeField"
}
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.33301.63517.11571</string> </value>
<value> <string>971.33401.54396.27033</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1541763469.75</float>
<float>1542962938.07</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -17,21 +17,20 @@
var i, j, tmp, value, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("lastBuildDate")) {
value = new Date(result.data.rows[i].value.lastBuildDate);
result.data.rows[i].value.lastBuildDate = {
field_gadget_param: {
allow_empty_time: 0,
ampm_time_style: 0,
//allow_empty_time: 0,
//ampm_time_style: 0,
css_class: "date_field",
date_only: 0,
description: "The Date",
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": value.toUTCString(),
"default": result.data.rows[i].value.lastBuildDate,
key: "lastBuildDate",
required: 0,
timezone_style: 0,
timezone_style: 1,
title: "Promise Date",
type: "DateTimeField"
}
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.33406.11946.46694</string> </value>
<value> <string>971.52364.9776.56234</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1541763839.91</float>
<float>1542962994.23</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -40,7 +40,6 @@
len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("date")) {
value = new Date(result.data.rows[i].value.date);
result.data.rows[i].value.date = {
field_gadget_param: {
allow_empty_time: 0,
......@@ -51,10 +50,10 @@
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": value.toUTCString(),
"default": result.data.rows[i].value.date,
key: "date",
required: 0,
timezone_style: 0,
timezone_style: 1,
title: "Status Date",
type: "DateTimeField"
}
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.13402.10882.46062</string> </value>
<value> <string>971.37886.23794.37102</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1542032541.78</float>
<float>1542965932.66</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -172,8 +172,8 @@
promise: options.doc,
jio_key: options.jio_key,
status: options.doc.category,
status_date: new Date(options.doc.pubDate),
report_date: new Date(options.doc.lastBuildDate),
status_date: options.doc.pubDate,
report_date: options.doc.lastBuildDate,
title: options.doc.source,
promise_output: options.doc.description,
private_url: pass_url,
......@@ -264,13 +264,12 @@
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": new Date(
status_history.data[i].date ||
status_history.data[i]['start-date']
).toUTCString(),
"default": (status_history.data[i].date ||
new Date(status_history.data[i]['start-date'])
.toUTCString()) + "+0000",
key: "start_date",
required: 0,
timezone_style: 0,
timezone_style: 1,
title: "Date",
type: "DateTimeField"
}
......@@ -285,13 +284,12 @@
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": new Date(
status_history.data[i]['change-date'] ||
status_history.data[i]['change-time'] * 1000
).toUTCString(),
"default": (status_history.data[i]['change-date'] ||
new Date(status_history.data[i]['change-time'] * 1000)
.toUTCString()) + "+0000",
key: "change_date",
required: 0,
timezone_style: 0,
timezone_style: 1,
title: "Status Date",
type: "DateTimeField"
}
......@@ -355,26 +353,26 @@
"your_status_date": {
"description": "",
"title": "Status Since",
"default": gadget.state.status_date.toUTCString(),
"default": gadget.state.status_date,
"css_class": "",
"required": 0,
"editable": 0,
"key": "status_date",
"hidden": 0,
"timezone_style": 0,
"timezone_style": 1,
"date_only": 0,
"type": "DateTimeField"
},
"your_report_date": {
"description": "",
"title": "Report Date",
"default": gadget.state.report_date.toUTCString(),
"default": gadget.state.report_date,
"css_class": "",
"required": 0,
"editable": 0,
"key": "report_date",
"hidden": 0,
"timezone_style": 0,
"timezone_style": 1,
"date_only": 0,
"type": "DateTimeField"
},
......@@ -518,7 +516,7 @@
"sort": [],
"hide_sort": true,
"command": "reload",
"title": "Promise Status list (On live)",
"title": "Promise Status History",
"type": "ListBox"
}
}},
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.40824.2567.53640</string> </value>
<value> <string>971.57749.10471.7526</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1542294280.54</float>
<float>1543224382.25</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -84,7 +84,7 @@
return gadget.changeState({
jio_key: options.jio_key,
status: gadget.state.instance.status,
report_date: new Date(gadget.state.instance.date),
report_date: gadget.state.instance.date,
title: current_document.title,
error: current_document.state.error,
success: current_document.state.success,
......@@ -120,7 +120,6 @@
var i, j, tmp, value, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("lastBuildDate")) {
value = new Date(result.data.rows[i].value.lastBuildDate);
result.data.rows[i].value.lastBuildDate = {
field_gadget_param: {
allow_empty_time: 0,
......@@ -131,10 +130,10 @@
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": value.toUTCString(),
"default": result.data.rows[i].value.lastBuildDate,
key: "lastBuildDate",
required: 0,
timezone_style: 0,
timezone_style: 1,
title: "Promise Date",
type: "DateTimeField"
}
......@@ -295,13 +294,13 @@
"your_report_date": {
"description": "",
"title": "Report Date",
"default": gadget.state.report_date.toUTCString(),
"default": gadget.state.report_date,
"css_class": "",
"required": 0,
"editable": 0,
"key": "report_date",
"hidden": 0,
"timezone_style": 0,
"timezone_style": 1,
"date_only": 0,
"type": "DateTimeField"
},
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.33402.59013.32563</string> </value>
<value> <string>971.52392.46096.61883</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1541763622.66</float>
<float>1542962862.93</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -108,7 +108,7 @@
<item>
<key> <string>text_content</string> </key>
<value> <string>CACHE MANIFEST\n
# generated on Fri, 16 Jul 2018 17:48:21 +0000\n
# generated on Fri, 19 Nov 2018 16:43:45 +0000\n
# XXX + fonts\n
# images/ajax-loader.gif\n
CACHE:\n
......@@ -149,6 +149,8 @@ gadget_erp5_router.html\n
gadget_erp5_router.js\n
gadget_html5_input.html\n
gadget_html5_input.js\n
gadget_erp5_configure_editor.html\n
gadget_erp5_configure_editor.js\n
gadget_erp5_searchfield.html\n
gadget_erp5_searchfield.js\n
gadget_erp5_pt_form_list.html\n
......@@ -387,7 +389,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.13516.48622.23296</string> </value>
<value> <string>971.57732.65002.56098</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -405,7 +407,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1540570672.89</float>
<float>1543224326.23</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.27666.8050.30907</string> </value>
<value> <string>971.43784.34275.28586</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1510935596.91</float>
<float>1542388521.4</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.38483.42476.54152</string> </value>
<value> <string>963.27666.8050.30907</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1507899173.02</float>
<float>1542277962.83</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -31,7 +31,34 @@
*/
var rusha = new Rusha(),
OPML_ATTACHMENT_NAME = "__opml__";
OPML_ATTACHMENT_NAME = "__opml__",
ZONE_LIST = [
"-1200",
"-1100",
"-1000",
"-0900",
"-0800",
"-0700",
"-0600",
"-0500",
"-0400",
"-0300",
"-0200",
"-0100",
"+0000",
"+0100",
"+0200",
"+0300",
"+0400",
"+0500",
"+0600",
"+0700",
"+0800",
"+0900",
"+1000",
"+1100",
"+1200"
];
function generateHash(str) {
return rusha.digestFromString(str);
......@@ -378,7 +405,7 @@
var status = element.status.toUpperCase();
if (hosting.instance_amount === 0) {
hosting.status_date = element.date;
hosting.status_date = fixDateTimezone(element.date);
}
if (hosting.status === "ERROR") {
return;
......@@ -391,6 +418,15 @@
}
}
function fixDateTimezone(date_string) {
// set default timezone offset to UTC
// XXX should be removed later
if (ZONE_LIST.indexOf(date_string.slice(-5)) === -1) {
return date_string + "+0000";
}
return date_string;
}
function getOpmlTree(context, opml_url, opml_spec, basic_login, opml_title) {
var opml_storage,
opml_document_list = [],
......@@ -412,7 +448,7 @@
opml_url: opml_url,
status: "WARNING",
instance_amount: 0,
status_date: new Date()
status_date: (new Date()).toUTCString() + "+0000"
};
return getDocumentAsAttachment(context, opml_url, OPML_ATTACHMENT_NAME)
.push(function (opml_doc) {
......@@ -579,6 +615,12 @@
// XXX - document need to be updated to keep compatibility
element = fixGlobalInstanceDocument(element);
}
// XXX - fixing date timezone
element.date = fixDateTimezone(element.date);
}
// XXX - fixing date timezone
if (element.pubDate !== undefined) {
element.pubDate = fixDateTimezone(element.pubDate);
}
id_hash = generateHash(item_result.parent_id +
......@@ -595,8 +637,8 @@
};
if (item_result.current_signature.hasOwnProperty(id_hash)) {
if (item_result.current_signature[id_hash].signature
=== signature) {
if (item_result.current_signature[id_hash].signature ===
signature) {
// the document was not modified return
delete item_result.current_signature[id_hash];
return;
......@@ -625,8 +667,8 @@
if (result_list[i].type === "promise") {
// the first element of rss is the header
extra_dict = {
lastBuildDate: result_list[i].result.data.rows[0].doc
.lastBuildDate,
lastBuildDate: fixDateTimezone(result_list[i].result.data.
rows[0].doc.lastBuildDate),
channel: result_list[i].result.data.rows[0].doc.description,
channel_item: result_list[i].result.data.rows[0].doc.title
};
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.42058.36320.56678</string> </value>
<value> <string>971.53440.65205.20872</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1540559911.98</float>
<float>1542966332.7</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment