http://trac.tiddlywiki.org/changeset/12349
MartinBudden
2010-08-05 02:56:12 -0700 (Thu, 05 Aug 2010)
72
Ticket #1239
Seconds in tiddler dates ignored when tiddlywiki is loaded
---------------
U Trunk/core/js/Dates.js
U Trunk/core/js/TW21Loader.js
U Trunk/core/test/js/Dates.js
---------------
Modified: Trunk/core/js/Dates.js
===================================================================
--- Trunk/core/js/Dates.js 2010-08-05 09:43:33 UTC (rev 12348)
+++ Trunk/core/js/Dates.js 2010-08-05 09:56:12 UTC (rev 12349)
@@ -93,6 +93,13 @@
return Date.convertFromYYYYMMDDHHMMSSMMM(d.substr(0,12));
};
+// Static method to create a date from a UTC YYYYMMDDHHMMSS format string
+Date.convertFromYYYYMMDDHHMMSS = function(d)
+{
+ d = d?d.replace(/[^0-9]/g, ""):"";
+ return Date.convertFromYYYYMMDDHHMMSSMMM(d.substr(0,14));
+};
+
// Static method to create a date from a UTC YYYYMMDDHHMMSSMMM format string
Date.convertFromYYYYMMDDHHMMSSMMM = function(d)
{
Modified: Trunk/core/js/TW21Loader.js
===================================================================
--- Trunk/core/js/TW21Loader.js 2010-08-05 09:43:33 UTC (rev 12348)
+++ Trunk/core/js/TW21Loader.js 2010-08-05 09:56:12 UTC (rev 12349)
@@ -38,8 +38,8 @@
var modifier = node.getAttribute("modifier");
var c = node.getAttribute("created");
var m = node.getAttribute("modified");
- var created = c ? Date.convertFromYYYYMMDDHHMM(c) : version.date;
- var modified = m ? Date.convertFromYYYYMMDDHHMM(m) : created;
+ var created = c ? Date.convertFromYYYYMMDDHHMMSS(c) : version.date;
+ var modified = m ? Date.convertFromYYYYMMDDHHMMSS(m) : created;
var tags = node.getAttribute("tags");
var fields = {};
var attrs = node.attributes;
Modified: Trunk/core/test/js/Dates.js
===================================================================
--- Trunk/core/test/js/Dates.js 2010-08-05 09:43:33 UTC (rev 12348)
+++ Trunk/core/test/js/Dates.js 2010-08-05 09:56:12 UTC (rev 12349)
@@ -461,6 +461,11 @@
same(Date.convertFromYYYYMMDDHHMMSSMMM(" 1999/12/15 12:57:19
678 "),new Date(Date.UTC(1999,11,15,12,57,19,678)),'should parse ignoring
whitespace');
same(Date.convertFromYYYYMMDDHHMMSSMMM(" 1999/12/15 12:57:19
678 GMT (BST) "),new Date(Date.UTC(1999,11,15,12,57,19,678)),'should parse
ignoring trailing text');
same(Date.convertFromYYYYMMDDHHMM(" 1999/12/15 12:57:19 678
GMT (BST) "),new Date(Date.UTC(1999,11,15,12,57,0,0)),'should parse ignoring
whitespace, punctuation and trailing text');
+ same(Date.convertFromYYYYMMDDHHMM(" 1999/12/15 12:57:xx
"),new Date(Date.UTC(1999,11,15,12,57,0,0)),'should parse ignoring whitespace,
punctuation and trailing text');
+ same(Date.convertFromYYYYMMDDHHMMSS("199912151257xx"),new
Date(Date.UTC(1999,11,15,12,57,0,0)),'should parse ignoring trailing text');
+ same(Date.convertFromYYYYMMDDHHMMSS("19991215125719"),new
Date(Date.UTC(1999,11,15,12,57,19,0)),'should parse including seconds');
+ same(Date.convertFromYYYYMMDDHHMMSS("19991215125709"),new
Date(Date.UTC(1999,11,15,12,57,9,0)),'should parse including seconds');
+ same(Date.convertFromYYYYMMDDHHMMSS("1999121512571"),new
Date(Date.UTC(1999,11,15,12,57,1,0)),'should parse including partial seconds');
var d1 = new Date(Date.UTC(1987,9,29,21,43,57,678));
var s1 = d1.convertToYYYYMMDDHHMMSSMMM();
var d2 = Date.convertFromYYYYMMDDHHMMSSMMM(s1);
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tiddlywikidev?hl=en.