1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-12 23:39:41 +00:00
TiddlyWiki5/editions/tw2/source/tiddlywiki/test/js/Dates.js
2012-11-16 21:20:27 +00:00

478 lines
26 KiB
JavaScript
Executable File

jQuery(document).ready(function(){
module("Dates");
test("Date functions", function() {
var actual = new Date(2008,11,31,9,48).formatString("0hh12");
var expected = "09";
same(actual,expected,'12-hour format (with zero-padding) should return correct result for AM times');
actual = new Date(2008,11,31,21,48).formatString("0hh12");
expected = "09";
same(actual,expected,'12-hour format (with zero-padding) should return correct result for PM times');
actual = new Date(2008,11,31,9,48).formatString("hh12");
expected = "9";
same(actual,expected,'12-hour format (without zero-padding) should return correct result for AM times');
actual = new Date(2008,11,31,21,48).formatString("hh12");
expected = "9";
same(actual,expected,'12-hour format (without zero-padding) should return correct result for PM times');
actual = new Date(2008,11,31,9,48).formatString("0hh");
expected = "09";
same(actual,expected,'24-hour format (with zero-padding) should return correct result for AM times');
actual = new Date(2008,11,31,21,48).formatString("0hh");
expected = "21";
same(actual,expected,'24-hour format (with zero-padding) should return correct result for PM times');
actual = new Date(2008,11,31,9,48).formatString("hh");
expected = "9";
same(actual,expected,'24-hour format (without zero-padding) should return correct result for AM times');
actual = new Date(2008,11,31,21,48).formatString("hh");
expected = "21";
same(actual,expected,'24-hour format (without zero-padding) should return correct result for PM times');
actual = new Date(2008,0).formatString("mmm");
expected = "Jan";
same(actual,expected,'short-month format should return "Jan" for month 0');
actual = new Date(2008,1).formatString("mmm");
expected = "Feb";
same(actual,expected,'short-month format should return "Feb" for month 1');
actual = new Date(2008,2).formatString("mmm");
expected = "Mar";
same(actual,expected,'short-month format should return "Mar" for month 2');
actual = new Date(2008,3).formatString("mmm");
expected = "Apr";
same(actual,expected,'short-month format should return "Apr" for month 3');
actual = new Date(2008,4).formatString("mmm");
expected = "May";
same(actual,expected,'short-month format should return "May" for month 4');
actual = new Date(2008,5).formatString("mmm");
expected = "Jun";
same(actual,expected,'short-month format should return "Jun" for month 5');
actual = new Date(2008,6).formatString("mmm");
expected = "Jul";
same(actual,expected,'short-month format should return "Jul" for month 6');
actual = new Date(2008,7).formatString("mmm");
expected = "Aug";
same(actual,expected,'short-month format should return "Aug" for month 7');
actual = new Date(2008,8).formatString("mmm");
expected = "Sep";
same(actual,expected,'short-month format should return "Sep" for month 8');
actual = new Date(2008,9).formatString("mmm");
expected = "Oct";
same(actual,expected,'short-month format should return "Oct" for month 9');
actual = new Date(2008,10).formatString("mmm");
expected = "Nov";
same(actual,expected,'short-month format should return "Nov" for month 10');
actual = new Date(2008,11).formatString("mmm");
expected = "Dec";
same(actual,expected,'short-month format should return "Dec" for month 12');
actual = new Date(2008,11,15,11,0).formatString("0mm");
expected = "00";
same(actual,expected,'minutes format (with zero-padding) should return "00" for minute 0');
actual = new Date(2008,11,15,11,5).formatString("0mm");
expected = "05";
same(actual,expected,'minutes format (with zero-padding) should return "05" for minute 5');
actual = new Date(2008,11,15,11,30).formatString("0mm");
expected = "30";
same(actual,expected,'minutes format (with zero-padding) should return "30" for minute 30');
actual = new Date(2008,11,15,11,60).formatString("0mm");
expected = "00";
same(actual,expected,'minutes format (with zero-padding) should return "00" for minute 60');
actual = new Date(2008,11,15,11,0).formatString("mm");
expected = "0";
same(actual,expected,'minutes format (without zero-padding) should return "0" for minute 0');
actual = new Date(2008,11,15,11,5).formatString("mm");
expected = "5";
same(actual,expected,'minutes format (without zero-padding) should return "5" for minute 5');
actual = new Date(2008,11,15,11,30).formatString("mm");
expected = "30";
same(actual,expected,'minutes format (without zero-padding) should return "30" for minute 30');
actual = new Date(2008,11,15,11,60).formatString("mm");
expected = "0";
same(actual,expected,'minutes format (without zero-padding) should return "0" for minute 60');
actual = new Date(2008,11,15,11,1,0).formatString("0ss");
expected = "00";
same(actual,expected,'seconds format (with zero-padding) should return "00" for second 0');
actual = new Date(2008,11,15,11,1,5).formatString("0ss");
expected = "05";
same(actual,expected,'seconds format (with zero-padding) should return "05" for second 5');
actual = new Date(2008,11,15,11,1,30).formatString("0ss");
expected = "30";
same(actual,expected,'seconds format (with zero-padding) should return "30" for second 30');
actual = new Date(2008,11,15,11,1,60).formatString("0ss");
expected = "00";
same(actual,expected,'seconds format (with zero-padding) should return "00" for second 60');
actual = new Date(2008,11,15,11,1,0).formatString("ss");
expected = "0";
same(actual,expected,'seconds format (without zero-padding) should return "0" for second 0');
actual = new Date(2008,11,15,11,1,5).formatString("ss");
expected = "5";
same(actual,expected,'seconds format (without zero-padding) should return "5" for second 5');
actual = new Date(2008,11,15,11,1,30).formatString("ss");
expected = "30";
same(actual,expected,'seconds format (without zero-padding) should return "30" for second 30');
actual = new Date(2008,11,15,11,1,60).formatString("ss");
expected = "0";
same(actual,expected,'seconds format (without zero-padding) should return "0" for second 60');
actual = new Date(2008,11,15,0).formatString("am");
expected = "am";
same(actual,expected,'am format should return "am" for pre-noon times (00:00:00)');
actual = new Date(2008,11,15,8).formatString("am");
expected = "am";
same(actual,expected,'am format should return "am" for pre-noon times (08:00:00)');
actual = new Date(2008,11,15,11,59,59).formatString("am");
expected = "am";
same(actual,expected,'am format should return "am" for pre-noon times (11:59:59)');
actual = new Date(2008,11,15,0).formatString("pm");
expected = "am";
same(actual,expected,'pm format should return "am" for pre-noon times (00:00:00)');
actual = new Date(2008,11,15,8).formatString("pm");
expected = "am";
same(actual,expected,'pm format should return "am" for pre-noon times (08:00:00)');
actual = new Date(2008,11,15,11,59,59).formatString("pm");
expected = "am";
same(actual,expected,'pm format should return "am" for pre-noon times (11:59:59)');
actual = new Date(2008,11,15,12).formatString("am");
expected = "pm";
same(actual,expected,'am format should return "pm" for pre-midnight times (12:00:00)');
actual = new Date(2008,11,15,20).formatString("am");
expected = "pm";
same(actual,expected,'am format should return "pm" for pre-midnight times (20:00:00)');
actual = new Date(2008,11,15,23,59,59).formatString("am");
expected = "pm";
same(actual,expected,'am format should return "pm" for pre-midnight times (23:59:59)');
actual = new Date(2008,11,15,12).formatString("pm");
expected = "pm";
same(actual,expected,'pm format should return "pm" for pre-midnight times (12:00:00)');
actual = new Date(2008,11,15,20).formatString("pm");
expected = "pm";
same(actual,expected,'pm format should return "pm" for pre-midnight times (20:00:00)');
actual = new Date(2008,11,15,23,59,59).formatString("pm");
expected = "pm";
same(actual,expected,'pm format should return "pm" for pre-midnight times (23:59:59)');
actual = new Date(2008,11,15,0).formatString("AM");
expected = "AM";
same(actual,expected,'AM format should return "AM" for pre-noon times (00:00:00)');
actual = new Date(2008,11,15,8).formatString("AM");
expected = "AM";
same(actual,expected,'AM format should return "AM" for pre-noon times (08:00:00)');
actual = new Date(2008,11,15,11,59,59).formatString("AM");
expected = "AM";
same(actual,expected,'AM format should return "AM" for pre-noon times (11:59:59)');
actual = new Date(2008,11,15,0).formatString("PM");
expected = "AM";
same(actual,expected,'PM format should return "AM" for pre-noon times (00:00:00)');
actual = new Date(2008,11,15,8).formatString("PM");
expected = "AM";
same(actual,expected,'PM format should return "AM" for pre-noon times (08:00:00)');
actual = new Date(2008,11,15,11,59,59).formatString("PM");
expected = "AM";
same(actual,expected,'PM format should return "AM" for pre-noon times (11:59:59)');
actual = new Date(2008,11,15,12).formatString("AM");
expected = "PM";
same(actual,expected,'AM format should return "PM" for pre-midnight times (12:00:00)');
actual = new Date(2008,11,15,20).formatString("AM");
expected = "PM";
same(actual,expected,'AM format should return "PM" for pre-midnight times (20:00:00)');
actual = new Date(2008,11,15,23,59,59).formatString("AM");
expected = "PM";
same(actual,expected,'AM format should return "PM" for pre-midnight times (23:59:59)');
actual = new Date(2008,11,15,12).formatString("PM");
expected = "PM";
same(actual,expected,'PM format should return "PM" for pre-midnight times (12:00:00)');
actual = new Date(2008,11,15,20).formatString("PM");
expected = "PM";
same(actual,expected,'PM format should return "PM" for pre-midnight times (20:00:00)');
actual = new Date(2008,11,15,23,59,59).formatString("PM");
expected = "PM";
same(actual,expected,'PM format should return "PM" for pre-midnight times (23:59:59)');
actual = new Date(2007,11,31).formatString("wYYYY");
expected = "2008";
same(actual,expected,'week-based four-digit year format should return the year based on the week number');
actual = new Date(2007,11,31).formatString("wYY");
expected = "08";
same(actual,expected,'week-based two-digit year format should return the year based on the week number');
actual = new Date(2007,11,31).formatString("YYYY");
expected = "2007";
same(actual,expected,'four-digit year format should return the correct year');
actual = new Date(7,11,31).formatString("YYYY");
expected = "1907";
same(actual,expected,'four-digit year format should return the correct year based on 20th century');
actual = new Date(2007,11,31).formatString("YY");
expected = "07";
same(actual,expected,'two-digit year format should return the correct year');
actual = new Date(2008,0).formatString("MMM");
expected = "January";
same(actual,expected,'full-month format should return "January" for month 0');
actual = new Date(2008,1).formatString("MMM");
expected = "February";
same(actual,expected,'full-month format should return "February" for month 1');
actual = new Date(2008,2).formatString("MMM");
expected = "March";
same(actual,expected,'full-month format should return "March" for month 2');
actual = new Date(2008,3).formatString("MMM");
expected = "April";
same(actual,expected,'full-month format should return "April" for month 3');
actual = new Date(2008,4).formatString("MMM");
expected = "May";
same(actual,expected,'full-month format should return "May" for month 4');
actual = new Date(2008,5).formatString("MMM");
expected = "June";
same(actual,expected,'full-month format should return "June" for month 5');
actual = new Date(2008,6).formatString("MMM");
expected = "July";
same(actual,expected,'full-month format should return "July" for month 6');
actual = new Date(2008,7).formatString("MMM");
expected = "August";
same(actual,expected,'full-month format should return "August" for month 7');
actual = new Date(2008,8).formatString("MMM");
expected = "September";
same(actual,expected,'full-month format should return "September" for month 8');
actual = new Date(2008,9).formatString("MMM");
expected = "October";
same(actual,expected,'full-month format should return "October" for month 9');
actual = new Date(2008,10).formatString("MMM");
expected = "November";
same(actual,expected,'full-month format should return "November" for month 10');
actual = new Date(2008,11).formatString("MMM");
expected = "December";
same(actual,expected,'full-month format should return "December" for month 12');
actual = new Date(2008,0).formatString("0MM");
expected = "01";
same(actual,expected,'months format (with zero-padding) should return "01" for January');
actual = new Date(2008,11).formatString("0MM");
expected = "12";
same(actual,expected,'months format (with zero-padding) should return "12" for December');
actual = new Date(2008,12).formatString("0MM");
expected = "01";
same(actual,expected,'months format (with zero-padding) should return "01" for month 13');
actual = new Date(2008,0).formatString("MM");
expected = "1";
same(actual,expected,'months format (without zero-padding) should return "1" for January');
actual = new Date(2008,11).formatString("MM");
expected = "12";
same(actual,expected,'months format (without zero-padding) should return "12" for December');
actual = new Date(2008,12).formatString("MM");
expected = "1";
same(actual,expected,'months format (without zero-padding) should return "1" for month 13');
actual = new Date(2008,0,3).formatString("0WW");
expected = "01";
same(actual,expected,'weeks format (with zero-padding) should return "01" for the first Thursday of the year');
actual = new Date(2008,11,28).formatString("0WW");
expected = "52";
same(actual,expected,'weeks format (with zero-padding) should return "52" for the last Sunday of the year');
actual = new Date(2008,0,1).formatString("WW");
expected = "1";
same(actual,expected,'weeks format (without zero-padding) should return "1" for the first day of the year');
actual = new Date(2008,11,28).formatString("WW");
expected = "52";
same(actual,expected,'weeks format (without zero-padding) should return "52" for the last Sunday of the year');
actual = new Date(2008,0,7).formatString("DDD");
expected = "Monday";
same(actual,expected,'full-day format should return "Monday" for the first day of the week');
actual = new Date(2008,0,8).formatString("DDD");
expected = "Tuesday";
same(actual,expected,'full-day format should return "Tuesday" for the second day of the week');
actual = new Date(2008,0,9).formatString("DDD");
expected = "Wednesday";
same(actual,expected,'full-day format should return "Wednesday" for the third day of the week');
actual = new Date(2008,0,10).formatString("DDD");
expected = "Thursday";
same(actual,expected,'full-day format should return "Thursday" for the fourth day of the week');
actual = new Date(2008,0,11).formatString("DDD");
expected = "Friday";
same(actual,expected,'full-day format should return "Friday" for the fifth day of the week');
actual = new Date(2008,0,12).formatString("DDD");
expected = "Saturday";
same(actual,expected,'full-day format should return "Saturday" for the sixth day of the week');
actual = new Date(2008,0,13).formatString("DDD");
expected = "Sunday";
same(actual,expected,'full-day format should return "Sunday" for the seventh day of the week');
actual = new Date(2008,0,7).formatString("ddd");
expected = "Mon";
same(actual,expected,'short-day format should return "Mon" for the first day of the week');
actual = new Date(2008,0,8).formatString("ddd");
expected = "Tue";
same(actual,expected,'short-day format should return "Tue" for the second day of the week');
actual = new Date(2008,0,9).formatString("ddd");
expected = "Wed";
same(actual,expected,'short-day format should return "Wed" for the third day of the week');
actual = new Date(2008,0,10).formatString("ddd");
expected = "Thu";
same(actual,expected,'short-day format should return "Thu" for the fourth day of the week');
actual = new Date(2008,0,11).formatString("ddd");
expected = "Fri";
same(actual,expected,'short-day format should return "Fri" for the fifth day of the week');
actual = new Date(2008,0,12).formatString("ddd");
expected = "Sat";
same(actual,expected,'short-day format should return "Sat" for the sixth day of the week');
actual = new Date(2008,0,13).formatString("ddd");
expected = "Sun";
same(actual,expected,'short-day format should return "Sun" for the seventh day of the week');
actual = new Date(2008,5,1).formatString("0DD");
expected = "01";
same(actual,expected,'days format (with zero-padding) should return "01" for the first day of the month');
actual = new Date(2008,0,31).formatString("0DD");
expected = "31";
same(actual,expected,'days format (with zero-padding) should return "31" for January 31');
actual = new Date(2008,0,32).formatString("0DD");
expected = "01";
same(actual,expected,'days format (with zero-padding) should return "01" for January 32 [sic]');
actual = new Date(2008,1,29).formatString("0DD");
expected = "29";
same(actual,expected,'days format (with zero-padding) should return "29" for February 29, 2008');
actual = new Date(2009,1,29).formatString("0DD");
expected = "01";
same(actual,expected,'days format (with zero-padding) should return "01" for February 29 [sic], 2009');
actual = new Date(2008,5,1).formatString("DD");
expected = "1";
same(actual,expected,'days format (without zero-padding) should return "1" for the first day of the month');
actual = new Date(2008,0,31).formatString("DD");
expected = "31";
same(actual,expected,'days format (without zero-padding) should return "31" for January 31');
actual = new Date(2008,0,32).formatString("DD");
expected = "1";
same(actual,expected,'days format (without zero-padding) should return "1" for January 32 [sic]');
actual = new Date(2008,1,29).formatString("DD");
expected = "29";
same(actual,expected,'days format (without zero-padding) should return "29" for February 29, 2008');
actual = new Date(2009,1,29).formatString("DD");
expected = "1";
same(actual,expected,'days format (without zero-padding) should return "1" for February 29 [sic], 2009');
actual = new Date(2008,5,1).formatString("DDth");
expected = "1st";
same(actual,expected,'day-with-suffix format should return "1st" for the first day of the month');
actual = new Date(2008,5,2).formatString("DDth");
expected = "2nd";
same(actual,expected,'day-with-suffix format should return "2nd" for the second day of the month');
actual = new Date(2008,5,3).formatString("DDth");
expected = "3rd";
same(actual,expected,'day-with-suffix format should return "3rd" for the third day of the month');
actual = new Date(2008,5,4).formatString("DDth");
expected = "4th";
same(actual,expected,'day-with-suffix format should return "4th" for the fourth day of the month');
actual = new Date(2008,5,11).formatString("DDth");
expected = "11th";
same(actual,expected,'day-with-suffix format should return "11th" for the eleventh day of the month');
actual = new Date(2008,5,21).formatString("DDth");
expected = "21st";
same(actual,expected,'day-with-suffix format should return "21st" for the twenty-first day of the month');
actual = new Date(2008,5,22).formatString("DDth");
expected = "22nd";
same(actual,expected,'day-with-suffix format should return "22nd" for the twenty-second day of the month');
actual = new Date(2008,5,23).formatString("DDth");
expected = "23rd";
same(actual,expected,'day-with-suffix format should return "23rd" for the twenty-third day of the month');
actual = new Date(2008,5,24).formatString("DDth");
expected = "24th";
same(actual,expected,'day-with-suffix format should return "24th" for the twenty-fourth day of the month');
actual = new Date(2008,0,32).formatString("DDth");
expected = "1st";
same(actual,expected,'day-with-suffix format should return "1st" for the January 32 [sic]');
});
test("Date: formatting", function() {
var actual = new Date(2007,2,1).formatString("YYYY MMM DD");
var expected = "2007 March 1";
same(actual,expected,'Date formatting YYYY MMM DD');
actual = new Date(2007,2,1).formatString("DD of MMM, YYYY");
expected = "1 of March, 2007";
same(actual,expected,'Given a format string including text (such as DD of MMM, YYYY) the date format outputs accordingly.');
actual = new Date(2008,11,31,23,48,59).formatString("YYYY MMM DD hh:mm ss");
expected = "2008 December 31 23:48 59";
same(actual,expected,'Date formatting YYYY MMM DD hh:mm ss');
actual = new Date(2008,11,31,3,8,9).formatString("0hh hh 0mm mm 0ss ss");
expected = "03 3 08 8 09 9";
same(actual,expected,'Date formatting hours, minutes & seconds');
actual = new Date(2008,11,31,3,8,9).formatString("hh12 0hh12 AM am PM pm");
expected = "3 03 AM am AM am";
same(actual,expected,'Date formatting 12-hour (AM)');
actual = new Date(2008,11,31,15,8,9).formatString("hh12 0hh12 AM am PM pm");
expected = "3 03 PM pm PM pm";
same(actual,expected,'Date formatting 12-hour (PM)');
actual = Date.convertFromYYYYMMDDHHMM("200812312348").toString();
expected = new Date(2008,11,31,23,48,0,0).toString();
same(actual,expected,'Date convertFromYYYYMMDDHHMM');
});
test("Date: information", function() {
var actual = new Date(2007,2,1,10,0).getAmPm();
var expected = "am";
same(actual,expected,'Given an AM time, getAmPm returns am');
actual = new Date(2007,2,1,13,0).getAmPm();
expected = "pm";
same(actual,expected,'Given an PM time, getAmPm returns pm');
actual = new Date(2007,2,1).daySuffix();
expected = "st";
same(actual,expected,'Give a valid date (1st), daySuffix returns the correct day Suffix ');
});
test("Date: escaping", function() {
var actual = new Date(2008,0,31,1,2,3).formatString("Y\\Y\\Y\\Y");
var expected = "YYYY";
same(actual,expected,'should not convert escaped four-digit year format');
actual = new Date(2008,0,31,1,2,3).formatString("Y\\Y");
expected = "YY";
same(actual,expected,'should not convert escaped two-digit year format');
});
test("Date: conversions", function() {
same(typeof Date.convertFromYYYYMMDDHHMMSSMMM,"function",'should parse define a function');
same(typeof Date.convertFromYYYYMMDDHHMMSSMMM("20070228"),"object",'should return an object');
var actual = Date.convertFromYYYYMMDDHHMMSSMMM();
ok(actual=="Invalid Date"||isNaN(actual),'should parse null value should be invalid');
actual = Date.convertFromYYYYMMDDHHMMSSMMM("2006"),
ok(actual=="Invalid Date"||isNaN(actual),'should parse year only should be invalid');
actual = Date.convertFromYYYYMMDDHHMMSSMMM("20061"),
ok(actual=="Invalid Date"||isNaN(actual),'should parse year, short month only should be invalid');
actual = Date.convertFromYYYYMMDDHHMMSSMMM("200601")
ok(actual=="Invalid Date"||isNaN(actual),'should parse year,month only should be invalid');
same(Date.convertFromYYYYMMDDHHMMSSMMM("20070228"),new Date(Date.UTC(2007,1,28)),'should parse date only');
same(Date.convertFromYYYYMMDDHHMMSSMMM("19691103"),new Date(Date.UTC(1969,10,3)),'should parse 1969 date only');
same(Date.convertFromYYYYMMDDHHMMSSMMM("2006011"),new Date(Date.UTC(2006,0,1)),'should parse year,month, short day');
same(Date.convertFromYYYYMMDDHHMMSSMMM("199912079"),new Date(Date.UTC(1999,11,7,9)),'should parse year,month,day short hour');
same(Date.convertFromYYYYMMDDHHMMSSMMM("1999121712"),new Date(Date.UTC(1999,11,17,12)),'should parse year,month,day,hour');
same(Date.convertFromYYYYMMDDHHMMSSMMM("199912598"),new Date(Date.UTC(1999,11,59,8)),'should parse year,month,day,hour short mins');
same(Date.convertFromYYYYMMDDHHMMSSMMM("199912150257"),new Date(Date.UTC(1999,11,15,2,57)),'should parse year,month,day,hour,mins');
same(Date.convertFromYYYYMMDDHHMMSSMMM("1999121512579"),new Date(Date.UTC(1999,11,15,12,57,9)),'should parse year,month,day,hour,mins,short secs');
same(Date.convertFromYYYYMMDDHHMMSSMMM("19991215125719"),new Date(Date.UTC(1999,11,15,12,57,19)),'should parse year,month,day,hour,mins,secs');
same(Date.convertFromYYYYMMDDHHMMSSMMM("199912151257198"),new Date(Date.UTC(1999,11,15,12,57,19,8)),'should parse year,month,day,hour,mins,secs,short milliseconds');
same(Date.convertFromYYYYMMDDHHMMSSMMM("1999121512571978"),new Date(Date.UTC(1999,11,15,12,57,19,78)),'should parse year,month,day,hour,mins,secs,medium milliseconds');
same(Date.convertFromYYYYMMDDHHMMSSMMM("19991215125719678"),new Date(Date.UTC(1999,11,15,12,57,19,678)),'should parse year,month,day,hour,mins,secs,long milliseconds');
same(Date.convertFromYYYYMMDDHHMMSSMMM("1999-12-15.12:57:19.678"),new Date(Date.UTC(1999,11,15,12,57,19,678)),'should parse ignoring punctuation');
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);
var s2 = d2.convertToYYYYMMDDHHMMSSMMM();
same(s2,s1,'should roundtrip current date from Date.convertToYYYYMMDDHHMMSSMMM');
same(d1,d2,'should roundtrip current date from Date.convertToYYYYMMDDHHMMSSMMM');
});
});