1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-12 13:33:44 +00:00

Add support for working with negative dates

See discussion https://groups.google.com/g/tiddlywiki/c/aHlyaHr93Io/m/vGcDa6lxAgAJ
This commit is contained in:
jeremy@jermolene.com
2020-12-01 10:39:27 +00:00
parent dde4182830
commit 6a91dbfe2f
5 changed files with 41 additions and 80 deletions

View File

@@ -305,7 +305,12 @@ $tw.utils.stringifyDate = function(value) {
// Parse a date from a UTC YYYYMMDDHHMMSSmmm format string
$tw.utils.parseDate = function(value) {
if(typeof value === "string") {
var year = parseInt(value.substr(0,4),10),
var negative = 1;
if(value.charAt(0) === "-") {
negative = -1;
value = value.substr(1);
}
var year = parseInt(value.substr(0,4),10) * negative,
d = new Date(Date.UTC(year,
parseInt(value.substr(4,2),10)-1,
parseInt(value.substr(6,2),10),