aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/date/relative_test.html
diff options
context:
space:
mode:
Diffstat (limited to 'contexts/data/lib/closure-library/closure/goog/date/relative_test.html')
-rw-r--r--contexts/data/lib/closure-library/closure/goog/date/relative_test.html151
1 files changed, 0 insertions, 151 deletions
diff --git a/contexts/data/lib/closure-library/closure/goog/date/relative_test.html b/contexts/data/lib/closure-library/closure/goog/date/relative_test.html
deleted file mode 100644
index 73042c8..0000000
--- a/contexts/data/lib/closure-library/closure/goog/date/relative_test.html
+++ /dev/null
@@ -1,151 +0,0 @@
-<!DOCTYPE html>
-
-<!--
--->
-
-<html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Test for goog.date.relative</title>
-<script src="../base.js"></script>
-<script>
- goog.LOCALE = 'en_US';
- goog.require('goog.testing.jsunit');
- goog.require('goog.date.relative');
- goog.require('goog.date.DateTime');
-</script>
-</head>
-<body>
-<script>
- // Timestamp to base times for test on.
- var baseTime = new Date(2009, 2, 23, 14, 31, 6).getTime();
-
- // Ensure goog.now returns a constant timestamp.
- goog.now = function() {
- return baseTime;
- };
-
-
- function testFormatRelativeForPastDates() {
- var fn = goog.date.relative.format;
-
- assertEquals('Should round seconds to the minute below',
- '0 minutes ago', fn(timestamp('23 March 2009 14:30:10')));
-
- assertEquals('Should round seconds to the minute below',
- '1 minute ago',
- fn(timestamp('23 March 2009 14:29:56')));
-
- assertEquals('Should round seconds to the minute below',
- '2 minutes ago', fn(timestamp('23 March 2009 14:29:00')));
-
- assertEquals('10 minutes ago', fn(timestamp('23 March 2009 14:20:10')));
- assertEquals('59 minutes ago', fn(timestamp('23 March 2009 13:31:42')));
- assertEquals('2 hours ago', fn(timestamp('23 March 2009 12:20:56')));
- assertEquals('23 hours ago', fn(timestamp('22 March 2009 15:30:56')));
- assertEquals('1 day ago', fn(timestamp('22 March 2009 12:11:04')));
- assertEquals('1 day ago', fn(timestamp('22 March 2009 00:00:00')));
- assertEquals('2 days ago', fn(timestamp('21 March 2009 23:59:59')));
- assertEquals('2 days ago', fn(timestamp('21 March 2009 10:30:56')));
- assertEquals('2 days ago', fn(timestamp('21 March 2009 00:00:00')));
- assertEquals('3 days ago', fn(timestamp('20 March 2009 23:59:59')));
- }
-
- function testFormatRelativeForFutureDates() {
- var fn = goog.date.relative.format;
-
- assertEquals('Should round seconds to the minute below',
- 'in 1 minute',
- fn(timestamp('23 March 2009 14:32:05')));
-
- assertEquals('Should round seconds to the minute below',
- 'in 2 minutes', fn(timestamp('23 March 2009 14:33:00')));
-
- assertEquals('in 10 minutes', fn(timestamp('23 March 2009 14:40:10')));
- assertEquals('in 59 minutes', fn(timestamp('23 March 2009 15:29:15')));
- assertEquals('in 2 hours', fn(timestamp('23 March 2009 17:20:56')));
- assertEquals('in 23 hours', fn(timestamp('24 March 2009 13:30:56')));
- assertEquals('in 1 day', fn(timestamp('24 March 2009 14:31:07')));
- assertEquals('in 1 day', fn(timestamp('24 March 2009 16:11:04')));
- assertEquals('in 1 day', fn(timestamp('24 March 2009 23:59:59')));
- assertEquals('in 2 days', fn(timestamp('25 March 2009 00:00:00')));
- assertEquals('in 2 days', fn(timestamp('25 March 2009 10:30:56')));
- assertEquals('in 2 days', fn(timestamp('25 March 2009 23:59:59')));
- assertEquals('in 3 days', fn(timestamp('26 March 2009 00:00:00')));
- }
-
-
- function testFormatPast() {
- var fn = goog.date.relative.formatPast;
-
- assertEquals('59 minutes ago', fn(timestamp('23 March 2009 13:31:42')));
- assertEquals('0 minutes ago', fn(timestamp('23 March 2009 14:32:05')));
- assertEquals('0 minutes ago', fn(timestamp('23 March 2009 14:33:00')));
- assertEquals('0 minutes ago', fn(timestamp('25 March 2009 10:30:56')));
- }
-
-
- function testFormatDay() {
- var fn = goog.date.relative.formatDay;
- assertEquals('Today', fn(timestamp('23 March 2009 10:31:06')));
- assertEquals('Today', fn(timestamp('23 March 2009 00:12:19')));
- assertEquals('Yesterday', fn(timestamp('22 March 2009 23:48:12')));
- assertEquals('Yesterday', fn(timestamp('22 March 2009 04:11:23')));
- assertEquals('Mar 21', fn(timestamp('21 March 2009 15:54:45')));
- assertEquals('Mar 19', fn(timestamp('19 March 2009 01:22:11')));
- }
-
- function testGetDateString() {
- var fn = goog.date.relative.getDateString;
-
- assertEquals('2:21 PM (10 minutes ago)',
- fn(new Date(baseTime - 10 * 60 * 1000)));
- assertEquals('4:31 AM (10 hours ago)',
- fn(new Date(baseTime - 10 * 60 * 60 * 1000)));
- assertEquals('Friday, March 13, 2009 (10 days ago)',
- fn(new Date(baseTime - 10 * 24 * 60 * 60 * 1000)));
- assertEquals('Tuesday, March 3, 2009',
- fn(new Date(baseTime - 20 * 24 * 60 * 60 * 1000)));
-
- // Test that goog.date.DateTime can also be accepted as input.
- assertEquals('2:21 PM (10 minutes ago)',
- fn(gdatetime(baseTime - 10 * 60 * 1000)));
- assertEquals('4:31 AM (10 hours ago)',
- fn(gdatetime(baseTime - 10 * 60 * 60 * 1000)));
- assertEquals('Friday, March 13, 2009 (10 days ago)',
- fn(gdatetime(baseTime - 10 * 24 * 60 * 60 * 1000)));
- assertEquals('Tuesday, March 3, 2009',
- fn(gdatetime(baseTime - 20 * 24 * 60 * 60 * 1000)));
- }
-
- function testGetPastDateString() {
- var fn = goog.date.relative.getPastDateString;
- assertEquals('2:21 PM (10 minutes ago)',
- fn(new Date(baseTime - 10 * 60 * 1000)));
- assertEquals('2:41 PM (0 minutes ago)',
- fn(new Date(baseTime + 10 * 60 * 1000)));
-
- // Test that goog.date.DateTime can also be accepted as input.
- assertEquals('2:21 PM (10 minutes ago)',
- fn(gdatetime(baseTime - 10 * 60 * 1000)));
- assertEquals('2:41 PM (0 minutes ago)',
- fn(gdatetime(baseTime + 10 * 60 * 1000)));
- }
-
- function gdatetime(timestamp) {
- return new goog.date.DateTime(new Date(timestamp));
- }
-
- function timestamp(str) {
- return new Date(str).getTime();
- }
-
-</script>
-</body>
-</html>