-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
123 lines (113 loc) · 3.07 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<style>
.wrong {
color: red;
}
</style>
<a href="http://github.com/yaffle/date-shim"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub"></a>
<ul>
<li><a href="http://github.com/yaffle/date-shim">date-shim</a>, <a href="https://github.com/kriskowal/es5-shim">es5-shim</a>, <a href="https://github.com/bestiejs/json3">json3</a></li>
<li><a href="http://www.hackcraft.net/web/datetime/">good page about UTC date format</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ff960802(v=vs.85).aspx">IE JS Date implementation</a></li>
<li><a href="https://bugs.ecmascript.org/show_bug.cgi?id=231">https://bugs.ecmascript.org/show_bug.cgi?id=231</a></li>
</ul>
<h1>Native</h1>
<div id="native"></div>
<h1>Fixed</h1>
<div id="fixed"></div>
<script>
if (!Date.now) {
Date.now = function () {
return -1;
};
}
if (!Date.prototype.getYear) {
Date.prototype.getYear = function () {
return -1;
};
}
if (!Date.prototype.setYear) {
Date.prototype.setYear = function () {
return -1;
};
}
if (!Date.prototype.toISOString) {
Date.prototype.toISOString = function () {
return '';
};
}
if (!Date.prototype.toJSON) {
Date.prototype.toJSON = function () {
return '';
};
}
if (!this.JSON) {
this.JSON = {
stringify: function (s) {
return (s && s.toJSON ? s.toJSON() : String(s));
}
};
}
var container = document.getElementById('native');
var path = [];
function describe(title, f) {
path.push(title);
if (beforeEachFunction !== null) {
beforeEachFunction();
}
f();
path.pop();
}
function it(title, f) {
describe(title, f);
}
var beforeEachFunction = null;
var counter = 0;
function expect(a) {
counter += 1;
function toBe(b) {
var s = counter + ') ' + path.join(' - ') + ', result: "' + a + '", exptected: "' + b + '"';
var x = document.createElement('div');
container.appendChild(x);
if (b !== a) {
//s += '<pre>' + (new Error()).stack + '</pre>';
x.className = 'wrong';
}
x.innerHTML = s;
}
return {
toBe: toBe,
toBeFalsy: function () {
a = !a;
return toBe(true);
},
toBeDefined: function (x) {
a = a !== undefined;
return toBe(true);
},
toEqual: function (x) {
return toBe(x);
},
toMatch: function (re) {
a = re.test(a);
return toBe(true);
},
toBeTruthy: function () {
a = Boolean(a);
return toBe(true);
}
};
}
function beforeEach(c) {
beforeEachFunction = c;
}
</script>
<script src="s-date.js"></script>
<script src="date-shim.js"></script>
<script>
counter = 0;
container = document.getElementById('fixed');
</script>
<script src="s-date.js"></script>
<script>
</script>