JSFiddle - React, Tailwind, and code Playground
by rosenfeld
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>strftime</title>
</head>
<body>
<script type="text/javascript" src="http://busterjs.org/releases/latest/buster-test.js"></script>
<script type="text/javascript" src="http://busterjs.org/examples/strftime/strftime.js"></script>
</body>
</html>
JavaScript
if (typeof require == "function" && typeof module == "object") {
buster = require("buster");
require("./strftime");
}
var assert = buster.assert;
buster.testCase("Date strftime tests", {
setUp: function () {
this.date = new Date(2009, 11, 5);
},
"%Y": {
setUp: function () {
this.year = this.date.strftime("%Y");
},
"should return full year": function () {
assert.equals(this.year, "2008");
},
"should return a string": function () {
assert.equals(typeof this.year, "string");
}
},
"%y should return two digit year": function () {
assert.equals(this.date.strftime("%y"), "09");
},
"%m should return month": function () {
assert.equals(this.date.strftime("%m"), "12");
},
"%d should return date": function () {
assert.equals(this.date.strftime("%d"), "05");
},
"//%j should return the day of the year": function () {
var date = new Date(2011, 0, 1);
assert.equals(date.strftime("%j"), 1);
}
});