diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index a38ca7f87..50784c2f7 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -1944,6 +1944,33 @@ Zotero.Sync.Server = new function () { }, 1); break; + case 'INVALID_TIMESTAMP': + var validClock = Zotero.DB.valueQuery("SELECT CURRENT_TIMESTAMP BETWEEN '1970-01-01 00:00:01' AND '2038-01-19 03:14:07'"); + if (!validClock) { + // TODO: localize + _error("The system clock is set to an invalid time. You will need to correct this to sync with the Zotero server."); + } + + setTimeout(function () { + Zotero.DB.beginTransaction(); + + var types = ['collections', 'creators', 'items', 'savedSearches', 'tags']; + for each (var type in types) { + var sql = "UPDATE " + type + " SET dateAdded=CURRENT_TIMESTAMP " + + "WHERE dateAdded NOT BETWEEN '1970-01-01 00:00:01' AND '2038-01-19 03:14:07'"; + Zotero.DB.query(sql); + var sql = "UPDATE " + type + " SET dateModified=CURRENT_TIMESTAMP " + + "WHERE dateModified NOT BETWEEN '1970-01-01 00:00:01' AND '2038-01-19 03:14:07'"; + Zotero.DB.query(sql); + var sql = "UPDATE " + type + " SET clientDateModified=CURRENT_TIMESTAMP " + + "WHERE clientDateModified NOT BETWEEN '1970-01-01 00:00:01' AND '2038-01-19 03:14:07'"; + Zotero.DB.query(sql); + } + + Zotero.DB.commitTransaction(); + }, 1); + break; + case 'UPGRADE_REQUIRED': Zotero.Sync.Server.upgradeRequired = true; break;