aboutsummaryrefslogtreecommitdiffstats
path: root/test/angular-mocks.js
diff options
context:
space:
mode:
authorIgor Minar2010-11-06 23:39:56 -0700
committerIgor Minar2010-11-08 22:46:41 -0800
commitf077649f48b2ad6f6dde42a2e425cf0d6066a820 (patch)
tree78a4c1f07ad40f7e3d0f501d91f123de1d94243c /test/angular-mocks.js
parentf3ac2cd434fd6ba142a5d7b31f9fba575e498579 (diff)
downloadangular.js-f077649f48b2ad6f6dde42a2e425cf0d6066a820.tar.bz2
TzDate should support various UTC methods
Diffstat (limited to 'test/angular-mocks.js')
-rw-r--r--test/angular-mocks.js37
1 files changed, 33 insertions, 4 deletions
diff --git a/test/angular-mocks.js b/test/angular-mocks.js
index f13ca763..0f637bf7 100644
--- a/test/angular-mocks.js
+++ b/test/angular-mocks.js
@@ -195,12 +195,17 @@ angular.service('$browser', function(){
function TzDate(offset, timestamp) {
if (angular.isString(timestamp)) {
var tsStr = timestamp;
- timestamp = angular.String.toDate(timestamp).getTime();
+
+ this.origDate = angular.String.toDate(timestamp);
+
+ timestamp = this.origDate.getTime();
if (isNaN(timestamp))
throw {
name: "Illegal Argument",
message: "Arg '" + tsStr + "' passed into TzDate constructor is not a valid date string"
};
+ } else {
+ this.origDate = new Date(timestamp);
}
var localOffset = new Date(timestamp).getTimezoneOffset();
@@ -243,10 +248,34 @@ function TzDate(offset, timestamp) {
return offset * 60;
};
+ this.getUTCFullYear = function() {
+ return this.origDate.getUTCFullYear();
+ };
+
+ this.getUTCMonth = function() {
+ return this.origDate.getUTCMonth();
+ };
+
+ this.getUTCDate = function() {
+ return this.origDate.getUTCDate();
+ };
+
+ this.getUTCHours = function() {
+ return this.origDate.getUTCHours();
+ };
+
+ this.getUTCMinutes = function() {
+ return this.origDate.getUTCMinutes();
+ };
+
+ this.getUTCSeconds = function() {
+ return this.origDate.getUTCSeconds();
+ };
+
+
//hide all methods not implemented in this mock that the Date prototype exposes
- var unimplementedMethods = ['getDay', 'getMilliseconds', 'getTime', 'getUTCDate', 'getUTCDay',
- 'getUTCFullYear', 'getUTCHours', 'getUTCMilliseconds', 'getUTCMinutes', 'getUTCMonth',
- 'getUTCSeconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds',
+ var unimplementedMethods = ['getDay', 'getMilliseconds', 'getTime', 'getUTCDay',
+ 'getUTCMilliseconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds',
'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear',
'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds',
'setYear', 'toDateString', 'toJSON', 'toGMTString', 'toLocaleFormat', 'toLocaleString',