summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-valid-date.js
blob: 8576c6bee9df6e7159395de2ffd33b12f9d23025 (plain)
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
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-date.prototype.getutcday
description: Return value for valid dates
info: |
  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return WeekDay(t).
---*/

var july6 = 1467763200000;
var july9 = 1468022400000;
var dayMs = 24 * 60 * 60 * 1000;

assert.sameValue(new Date(july6).getUTCDay(), 3, 'first millisecond');
assert.sameValue(
  new Date(july6 - 1).getUTCDay(), 2, 'previous millisecond'
);
assert.sameValue(
  new Date(july6 + dayMs - 1).getUTCDay(), 3, 'final millisecond'
);
assert.sameValue(
  new Date(july6 + dayMs).getUTCDay(), 4, 'subsequent millisecond'
);

assert.sameValue(
  new Date(july9).getUTCDay(), 6, 'first millisecond (week boundary)'
);
assert.sameValue(
  new Date(july9 - 1).getUTCDay(), 5, 'previous millisecond (week boundary)'
);
assert.sameValue(
  new Date(july9 + dayMs - 1).getUTCDay(),
  6,
  'final millisecond (week boundary)'
);
assert.sameValue(
  new Date(july9 + dayMs).getUTCDay(),
  0,
  'subsequent millisecond (week boundary)'
);

reportCompare(0, 0);