??????????????????????????????
???????????? ???????[ 2012/10/9 11:57:42 ] ????????
????????????Щ?????????????????????????????????????
var dateUtil = {};
(function () {
var units = {
second: 1000??
minute: 1000 * 60??
hour: 1000 * 60 * 60??
day: 1000 * 60 * 60 * 24??
week: 1000 * 60 * 60 * 24 * 7??
month: 1000 * 60 * 60 * 24 * 30
};
function format(num?? type) {
return num + " " + type + (num > 1 ? "s" : "");
}
dateUtil.differenceInWords = function (date) {
// return correct string
};
jQuery.fn.differenceInWords = function () {
this.each(function () {
var datetime = this.getAttribute("datetime");
this.innerHTML = dateUtil.differenceInWords(new Date(datetime));
});
};
}());
??????????????????????????????????????????????????????????????????jQuery??????μ?dateUtil.differenceInWords????????????????????????????????????к???????????????????????????????????????????????????????????????????????jQuery?????????滻????innerHTML??????????????????μ????????????μ????????????????????????????????????μ???д??????????????????
TestCase("TimeDifferenceInWordsTest"?? {
setUp: function () {
this.date8DaysAgo = new Date(new Date() - 8 * day);
var diff = 3 * day + 2 * hour + 16 * minute + 10 * second;
this.date3DaysAgo = new Date(new Date() - diff);
}??
"test 8 day difference should result in '1 week ago'": function () {
assertEquals("1 week ago"?? dateUtil.differenceInWords(this.date8DaysAgo));
}??
"test should display difference with days?? hours?? minutes and seconds": function () {
assertEquals("3 days?? 2 hours?? 16 minutes and 10 seconds ago"??
dateUtil.differenceInWords(this.date3DaysAgo));
}
});
????????????????????????????κ?DOM??????????????????Ч????????????????????????????????????jQuery??????????????????????????滻???????
???????????????????
????????????Щ????????????????????????????????????Щ????????????“??????????????????д????????????????Щ??????????”
?????????????????????????????????????????????????????????????????????а????????????????仹??????????????????????з?????????????????????????????????????????????Twitter??????????????????????differenceInWords?????????????DOM????jQuery??????????????????
???????????????????????????????????????????????????????????????????????????????????????????????Щ???С????????——??????????????——??????????????????????ζ??????????????á?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11