rasputin 0.10.7 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -21
- data/lib/rasputin/handlebars/compiler.rb +1 -1
- data/lib/rasputin/handlebars/handlebars.js +20 -20
- data/lib/rasputin/handlebars/template.rb +2 -2
- data/lib/rasputin/version.rb +1 -1
- data/rasputin.gemspec +2 -2
- data/vendor/assets/javascripts/{sproutcore-datastore.js → ember-datastore.js} +925 -925
- data/vendor/assets/javascripts/{sproutcore-datetime.js → ember-datetime.js} +99 -99
- data/vendor/assets/javascripts/ember-i18n.js +21 -0
- data/vendor/assets/javascripts/{sproutcore-routing.js → ember-routing.js} +26 -26
- data/vendor/assets/javascripts/{sproutcore-touch.js → ember-touch.js} +91 -93
- data/vendor/assets/javascripts/{sproutcore.js → ember.js} +1369 -1355
- metadata +18 -20
- data/vendor/assets/javascripts/sproutcore-i18n.js +0 -21
- data/vendor/assets/javascripts/sproutcore-statechart.js +0 -3265
- data/vendor/assets/javascripts/sproutcore-utils.js +0 -73
@@ -1,12 +1,12 @@
|
|
1
1
|
(function() {
|
2
2
|
// ==========================================================================
|
3
|
-
// Project:
|
3
|
+
// Project: Ember - JavaScript Application Framework
|
4
4
|
// Copyright: ©2006-2011 Strobe Inc. and contributors.
|
5
5
|
// Portions ©2008-2011 Apple Inc. All rights reserved.
|
6
6
|
// License: Licensed under MIT license (see license.js)
|
7
7
|
// ==========================================================================
|
8
8
|
|
9
|
-
var get =
|
9
|
+
var get = Ember.get, set = Ember.set;
|
10
10
|
|
11
11
|
// simple copy op needed for just this code.
|
12
12
|
function copy(opts) {
|
@@ -18,41 +18,41 @@ function copy(opts) {
|
|
18
18
|
}
|
19
19
|
|
20
20
|
/**
|
21
|
-
Standard error thrown by `
|
21
|
+
Standard error thrown by `Ember.Scanner` when it runs out of bounds
|
22
22
|
|
23
23
|
@static
|
24
24
|
@constant
|
25
25
|
@type Error
|
26
26
|
*/
|
27
|
-
|
27
|
+
Ember.EmberANNER_OUT_OF_BOUNDS_ERROR = "Out of bounds.";
|
28
28
|
|
29
29
|
/**
|
30
|
-
Standard error thrown by `
|
30
|
+
Standard error thrown by `Ember.Scanner` when you pass a value not an integer.
|
31
31
|
|
32
32
|
@static
|
33
33
|
@constant
|
34
34
|
@type Error
|
35
35
|
*/
|
36
|
-
|
36
|
+
Ember.EmberANNER_INT_ERROR = "Not an int.";
|
37
37
|
|
38
38
|
/**
|
39
|
-
Standard error thrown by `
|
39
|
+
Standard error thrown by `Ember.Scanner` when it cannot find a string to skip.
|
40
40
|
|
41
41
|
@static
|
42
42
|
@constant
|
43
43
|
@type Error
|
44
44
|
*/
|
45
|
-
|
45
|
+
Ember.EmberANNER_SKIP_ERROR = "Did not find the string to skip.";
|
46
46
|
|
47
47
|
/**
|
48
|
-
Standard error thrown by `
|
48
|
+
Standard error thrown by `Ember.Scanner` when it can any kind a string in the
|
49
49
|
matching array.
|
50
50
|
|
51
51
|
@static
|
52
52
|
@constant
|
53
53
|
@type Error
|
54
54
|
*/
|
55
|
-
|
55
|
+
Ember.EmberANNER_EmberAN_ARRAY_ERROR = "Did not find any string of the given array to scan.";
|
56
56
|
|
57
57
|
/**
|
58
58
|
Standard error thrown when trying to compare two dates in different
|
@@ -62,7 +62,7 @@ SC.SCANNER_SCAN_ARRAY_ERROR = "Did not find any string of the given array to sca
|
|
62
62
|
@constant
|
63
63
|
@type Error
|
64
64
|
*/
|
65
|
-
|
65
|
+
Ember.DATETIME_COMPAREDATE_TIMEZONE_ERROR = "Can't compare the dates of two DateTimes that don't have the same timezone.";
|
66
66
|
|
67
67
|
/**
|
68
68
|
Standard ISO8601 date format
|
@@ -72,7 +72,7 @@ SC.DATETIME_COMPAREDATE_TIMEZONE_ERROR = "Can't compare the dates of two DateTim
|
|
72
72
|
@default '%Y-%m-%dT%H:%M:%S%Z'
|
73
73
|
@constant
|
74
74
|
*/
|
75
|
-
|
75
|
+
Ember.DATETIME_ISO8601 = '%Y-%m-%dT%H:%M:%S%Z';
|
76
76
|
|
77
77
|
|
78
78
|
/**
|
@@ -86,11 +86,11 @@ SC.DATETIME_ISO8601 = '%Y-%m-%dT%H:%M:%S%Z';
|
|
86
86
|
|
87
87
|
Scanners are used by `DateTime` to convert strings into `DateTime` objects.
|
88
88
|
|
89
|
-
@extends
|
89
|
+
@extends Ember.Object
|
90
90
|
@since SproutCore 1.0
|
91
91
|
@author Martin Ottenwaelter
|
92
92
|
*/
|
93
|
-
var Scanner =
|
93
|
+
var Scanner = Ember.Object.extend({
|
94
94
|
|
95
95
|
/**
|
96
96
|
The string to scan. You usually pass it to the create method:
|
@@ -115,12 +115,12 @@ var Scanner = SC.Object.extend({
|
|
115
115
|
accordingly.
|
116
116
|
|
117
117
|
@param {Integer} len The amount of characters to read
|
118
|
-
@throws {
|
118
|
+
@throws {Ember.EmberANNER_OUT_OF_BOUNDS_ERROR} If asked to read too many characters
|
119
119
|
@returns {String} The characters
|
120
120
|
*/
|
121
121
|
scan: function(len) {
|
122
122
|
if (this.scanLocation + len > this.length) {
|
123
|
-
throw new Error(
|
123
|
+
throw new Error(Ember.EmberANNER_OUT_OF_BOUNDS_ERROR);
|
124
124
|
}
|
125
125
|
var str = this.string.substr(this.scanLocation, len);
|
126
126
|
this.scanLocation += len;
|
@@ -132,7 +132,7 @@ var Scanner = SC.Object.extend({
|
|
132
132
|
|
133
133
|
@param {Integer} min_len The minimum amount of characters to read
|
134
134
|
@param {Integer} [max_len] The maximum amount of characters to read (defaults to the minimum)
|
135
|
-
@throws {
|
135
|
+
@throws {Ember.EmberANNER_INT_ERROR} If asked to read non numeric characters
|
136
136
|
@returns {Integer} The scanned integer
|
137
137
|
*/
|
138
138
|
scanInt: function(min_len, max_len) {
|
@@ -140,7 +140,7 @@ var Scanner = SC.Object.extend({
|
|
140
140
|
var str = this.scan(max_len);
|
141
141
|
var re = new RegExp("^\\d{" + min_len + "," + max_len + "}");
|
142
142
|
var match = str.match(re);
|
143
|
-
if (!match) throw new Error(
|
143
|
+
if (!match) throw new Error(Ember.EmberANNER_INT_ERROR);
|
144
144
|
if (match[0].length < max_len) {
|
145
145
|
this.scanLocation += match[0].length - max_len;
|
146
146
|
}
|
@@ -151,12 +151,12 @@ var Scanner = SC.Object.extend({
|
|
151
151
|
Attempts to skip a given string.
|
152
152
|
|
153
153
|
@param {String} str The string to skip
|
154
|
-
@throws {
|
154
|
+
@throws {Ember.EmberANNER_SKIP_ERROR} If the given string could not be scanned
|
155
155
|
@returns {Boolean} YES if the given string was successfully scanned, NO otherwise
|
156
156
|
*/
|
157
157
|
skipString: function(str) {
|
158
158
|
if (this.scan(str.length) !== str) {
|
159
|
-
throw new Error(
|
159
|
+
throw new Error(Ember.EmberANNER_SKIP_ERROR);
|
160
160
|
}
|
161
161
|
|
162
162
|
return YES;
|
@@ -166,7 +166,7 @@ var Scanner = SC.Object.extend({
|
|
166
166
|
Attempts to scan any string in a given array.
|
167
167
|
|
168
168
|
@param {Array} ary the array of strings to scan
|
169
|
-
@throws {
|
169
|
+
@throws {Ember.EmberANNER_EmberAN_ARRAY_ERROR} If no string of the given array is found
|
170
170
|
@returns {Integer} The index of the scanned string of the given array
|
171
171
|
*/
|
172
172
|
scanArray: function(ary) {
|
@@ -176,7 +176,7 @@ var Scanner = SC.Object.extend({
|
|
176
176
|
}
|
177
177
|
this.scanLocation -= ary[i].length;
|
178
178
|
}
|
179
|
-
throw new Error(
|
179
|
+
throw new Error(Ember.EmberANNER_EmberAN_ARRAY_ERROR);
|
180
180
|
}
|
181
181
|
|
182
182
|
});
|
@@ -191,12 +191,12 @@ var Scanner = SC.Object.extend({
|
|
191
191
|
This object differs from the standard JS Date object, however, in that it
|
192
192
|
supports time zones other than UTC and that local to the machine on which
|
193
193
|
it is running. Any time zone can be specified when creating an
|
194
|
-
`
|
194
|
+
`Ember.DateTime` object, e.g.
|
195
195
|
|
196
196
|
// Creates a DateTime representing 5am in Washington, DC and 10am in
|
197
197
|
// London
|
198
|
-
var d =
|
199
|
-
var e =
|
198
|
+
var d = Ember.DateTime.create({ hour: 5, timezone: 300 }); // -5 hours from UTC
|
199
|
+
var e = Ember.DateTime.create({ hour: 10, timezone: 0 }); // same time, specified in UTC
|
200
200
|
|
201
201
|
and it is true that `d.isEqual(e)`.
|
202
202
|
|
@@ -212,16 +212,16 @@ var Scanner = SC.Object.extend({
|
|
212
212
|
|
213
213
|
is true, since they are technically the same position in time.
|
214
214
|
|
215
|
-
@extends
|
216
|
-
@extends
|
217
|
-
@extends
|
215
|
+
@extends Ember.Object
|
216
|
+
@extends Ember.Freezable
|
217
|
+
@extends Ember.Copyable
|
218
218
|
@author Martin Ottenwaelter
|
219
219
|
@author Jonathan Lewis
|
220
220
|
@author Josh Holt
|
221
221
|
@since SproutCore 1.0
|
222
222
|
*/
|
223
|
-
|
224
|
-
/** @scope
|
223
|
+
Ember.DateTime = Ember.Object.extend(Ember.Freezable, Ember.Copyable,
|
224
|
+
/** @scope Ember.DateTime.prototype */ {
|
225
225
|
|
226
226
|
/**
|
227
227
|
@private
|
@@ -244,29 +244,29 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable,
|
|
244
244
|
timezone: 0,
|
245
245
|
|
246
246
|
/**
|
247
|
-
A `
|
247
|
+
A `Ember.DateTime` instance is frozen by default for better performance.
|
248
248
|
|
249
249
|
@type Boolean
|
250
250
|
*/
|
251
251
|
isFrozen: YES,
|
252
252
|
|
253
253
|
/**
|
254
|
-
Returns a new `
|
254
|
+
Returns a new `Ember.DateTime` object where one or more of the elements have
|
255
255
|
been changed according to the options parameter. The time options (hour,
|
256
256
|
minute, sec, usec) reset cascadingly, so if only the hour is passed, then
|
257
257
|
minute, sec, and usec is set to 0. If the hour and minute is passed, then
|
258
258
|
sec and usec is set to 0.
|
259
259
|
|
260
260
|
If a time zone is passed in the options hash, all dates and times are
|
261
|
-
assumed to be local to it, and the returned `
|
262
|
-
that time zone. If none is passed, it defaults to `
|
261
|
+
assumed to be local to it, and the returned `Ember.DateTime` instance has
|
262
|
+
that time zone. If none is passed, it defaults to `Ember.DateTime.timezone`.
|
263
263
|
|
264
264
|
Note that passing only a time zone does not affect the actual milliseconds
|
265
265
|
since Jan 1, 1970, only the time zone in which it is expressed when
|
266
266
|
displayed.
|
267
267
|
|
268
|
-
@see
|
269
|
-
@returns {
|
268
|
+
@see Ember.DateTime#create for the list of options you can pass
|
269
|
+
@returns {Ember.DateTime} copy of receiver
|
270
270
|
*/
|
271
271
|
adjust: function(options, resetCascadingly) {
|
272
272
|
var timezone;
|
@@ -278,10 +278,10 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable,
|
|
278
278
|
},
|
279
279
|
|
280
280
|
/**
|
281
|
-
Returns a new `
|
281
|
+
Returns a new `Ember.DateTime` object advanced according the the given
|
282
282
|
parameters. Don't use floating point values, it might give unpredicatble results.
|
283
283
|
|
284
|
-
@see
|
284
|
+
@see Ember.DateTime#create for the list of options you can pass
|
285
285
|
@param {Hash} options the amount of date/time to advance the receiver
|
286
286
|
@returns {DateTime} copy of the receiver
|
287
287
|
*/
|
@@ -372,7 +372,7 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable,
|
|
372
372
|
@return {String} the formatted string
|
373
373
|
*/
|
374
374
|
toISO8601: function(){
|
375
|
-
return this.constructor._toFormattedString(
|
375
|
+
return this.constructor._toFormattedString(Ember.DATETIME_ISO8601, this._ms, this.timezone);
|
376
376
|
},
|
377
377
|
|
378
378
|
/**
|
@@ -381,9 +381,9 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable,
|
|
381
381
|
Creates a string representation of the receiver.
|
382
382
|
|
383
383
|
(Debuggers often call the `toString` method. Because of the way
|
384
|
-
`
|
384
|
+
`Ember.DateTime` is designed, calling `Ember.DateTime._toFormattedString` would
|
385
385
|
have a nasty side effect. We shouldn't therefore call any of
|
386
|
-
`
|
386
|
+
`Ember.DateTime`'s methods from `toString`)
|
387
387
|
|
388
388
|
@returns {String}
|
389
389
|
*/
|
@@ -395,12 +395,12 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable,
|
|
395
395
|
},
|
396
396
|
|
397
397
|
/**
|
398
|
-
Returns `YES` if the passed `
|
398
|
+
Returns `YES` if the passed `Ember.DateTime` is equal to the receiver, ie: if their
|
399
399
|
number of milliseconds since January, 1st 1970 00:00:00.0 UTC are equal.
|
400
400
|
This is the preferred method for testing equality.
|
401
401
|
|
402
|
-
@see
|
403
|
-
@param {
|
402
|
+
@see Ember.DateTime#compare
|
403
|
+
@param {Ember.DateTime} aDateTime the DateTime to compare to
|
404
404
|
@returns {Boolean}
|
405
405
|
*/
|
406
406
|
isEqual: function(aDateTime) {
|
@@ -408,10 +408,10 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable,
|
|
408
408
|
},
|
409
409
|
|
410
410
|
/**
|
411
|
-
Returns a copy of the receiver. Because of the way `
|
411
|
+
Returns a copy of the receiver. Because of the way `Ember.DateTime` is designed,
|
412
412
|
it just returns the receiver.
|
413
413
|
|
414
|
-
@returns {
|
414
|
+
@returns {Ember.DateTime}
|
415
415
|
*/
|
416
416
|
copy: function() {
|
417
417
|
return this;
|
@@ -419,7 +419,7 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable,
|
|
419
419
|
|
420
420
|
/**
|
421
421
|
Returns a copy of the receiver with the timezone set to the passed
|
422
|
-
timezone. The returned value is equal to the receiver (ie `
|
422
|
+
timezone. The returned value is equal to the receiver (ie `Ember.Compare`
|
423
423
|
returns 0), it is just the timezone representation that changes.
|
424
424
|
|
425
425
|
If you don't pass any argument, the target timezone is assumed to be 0,
|
@@ -429,7 +429,7 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable,
|
|
429
429
|
but only the time zone in which it is displayed. In other words, the underlying
|
430
430
|
number of milliseconds since Jan 1, 1970 does not change.
|
431
431
|
|
432
|
-
@return {
|
432
|
+
@return {Ember.DateTime}
|
433
433
|
*/
|
434
434
|
toTimezone: function(timezone) {
|
435
435
|
if (timezone === undefined) timezone = 0;
|
@@ -438,8 +438,8 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable,
|
|
438
438
|
|
439
439
|
});
|
440
440
|
|
441
|
-
|
442
|
-
/** @scope
|
441
|
+
Ember.DateTime.reopenClass(Ember.Comparable,
|
442
|
+
/** @scope Ember.DateTime */ {
|
443
443
|
|
444
444
|
/**
|
445
445
|
The default format (ISO 8601) in which DateTimes are stored in a record.
|
@@ -449,12 +449,12 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
449
449
|
This value can also be customized on a per-attribute basis with the format
|
450
450
|
property. For example:
|
451
451
|
|
452
|
-
|
452
|
+
Ember.Record.attr(Ember.DateTime, { format: '%d/%m/%Y %H:%M:%S' })
|
453
453
|
|
454
454
|
@type String
|
455
|
-
@default
|
455
|
+
@default Ember.DATETIME_ISO8601
|
456
456
|
*/
|
457
|
-
recordFormat:
|
457
|
+
recordFormat: Ember.DATETIME_ISO8601,
|
458
458
|
|
459
459
|
/**
|
460
460
|
@type Array
|
@@ -497,8 +497,8 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
497
497
|
application and manipulating it with `setTime()` and `getTime()`.
|
498
498
|
|
499
499
|
Note that since this is used for internal calculations across many
|
500
|
-
`
|
501
|
-
any one `
|
500
|
+
`Ember.DateTime` instances, it is not guaranteed to store the date/time that
|
501
|
+
any one `Ember.DateTime` instance represents. So it might be that
|
502
502
|
|
503
503
|
this._date.getTime() !== this._ms
|
504
504
|
|
@@ -512,7 +512,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
512
512
|
@private
|
513
513
|
|
514
514
|
The offset, in minutes, between UTC and the currently manipulated
|
515
|
-
`
|
515
|
+
`Ember.DateTime` instance.
|
516
516
|
|
517
517
|
@type Integer
|
518
518
|
*/
|
@@ -531,7 +531,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
531
531
|
/**
|
532
532
|
@private
|
533
533
|
|
534
|
-
A cache of `
|
534
|
+
A cache of `Ember.DateTime` instances. If you attempt to create a `Ember.DateTime`
|
535
535
|
instance that has already been created, then it will return the cached
|
536
536
|
value.
|
537
537
|
|
@@ -602,7 +602,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
602
602
|
|
603
603
|
/**
|
604
604
|
@private
|
605
|
-
@see
|
605
|
+
@see Ember.DateTime#unknownProperty
|
606
606
|
*/
|
607
607
|
_get: function(key, start, timezone) {
|
608
608
|
var ms, tz, doy, m, y, firstDayOfWeek, dayOfWeek, dayOfYear, prefix, suffix;
|
@@ -756,7 +756,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
756
756
|
|
757
757
|
/**
|
758
758
|
@private
|
759
|
-
@see
|
759
|
+
@see Ember.DateTime#advance
|
760
760
|
*/
|
761
761
|
_advance: function(options, start, timezone) {
|
762
762
|
var opts = options ? copy(options) : {};
|
@@ -789,7 +789,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
789
789
|
// Note that this object was created in the local machine time zone, so when we set
|
790
790
|
// its params later, it will be assuming these values to be in the same time zone as it is.
|
791
791
|
// It's ok for start to be null, in which case we'll just keep whatever we had in 'd' before.
|
792
|
-
if (!
|
792
|
+
if (!Ember.none(start)) {
|
793
793
|
d.setTime(start); // using milliseconds here specifies an absolute location in time, regardless of time zone, so that's nice
|
794
794
|
}
|
795
795
|
|
@@ -807,15 +807,15 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
807
807
|
// the time options (hour, minute, sec, millisecond)
|
808
808
|
// reset cascadingly (see documentation)
|
809
809
|
if (resetCascadingly === undefined || resetCascadingly === YES) {
|
810
|
-
if ( !
|
810
|
+
if ( !Ember.none(opts.hour) && Ember.none(opts.minute)) {
|
811
811
|
opts.minute = 0;
|
812
812
|
}
|
813
|
-
if (!(
|
814
|
-
&&
|
813
|
+
if (!(Ember.none(opts.hour) && Ember.none(opts.minute))
|
814
|
+
&& Ember.none(opts.second)) {
|
815
815
|
opts.second = 0;
|
816
816
|
}
|
817
|
-
if (!(
|
818
|
-
&&
|
817
|
+
if (!(Ember.none(opts.hour) && Ember.none(opts.minute) && Ember.none(opts.second))
|
818
|
+
&& Ember.none(opts.millisecond)) {
|
819
819
|
opts.millisecond = 0;
|
820
820
|
}
|
821
821
|
}
|
@@ -825,13 +825,13 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
825
825
|
// according to javascript Date spec, you have to set year, month, and day together
|
826
826
|
// if you're setting any one of them. So we'll use the provided Date.UTC() method
|
827
827
|
// to get milliseconds, and we need to get any missing values first...
|
828
|
-
if (
|
829
|
-
if (
|
830
|
-
if (
|
831
|
-
if (
|
832
|
-
if (
|
833
|
-
if (
|
834
|
-
if (
|
828
|
+
if (Ember.none(opts.year)) opts.year = d.getUTCFullYear();
|
829
|
+
if (Ember.none(opts.month)) opts.month = d.getUTCMonth() + 1; // January is 0 in JavaScript
|
830
|
+
if (Ember.none(opts.day)) opts.day = d.getUTCDate();
|
831
|
+
if (Ember.none(opts.hour)) opts.hour = d.getUTCHours();
|
832
|
+
if (Ember.none(opts.minute)) opts.minute = d.getUTCMinutes();
|
833
|
+
if (Ember.none(opts.second)) opts.second = d.getUTCSeconds();
|
834
|
+
if (Ember.none(opts.millisecond)) opts.millisecond = d.getUTCMilliseconds();
|
835
835
|
|
836
836
|
// Ask the JS Date to calculate milliseconds for us (still in redefined UTC). It
|
837
837
|
// is best to set them all together because, for example, a day value means different things
|
@@ -852,17 +852,17 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
852
852
|
},
|
853
853
|
|
854
854
|
/**
|
855
|
-
Returns a new `
|
855
|
+
Returns a new `Ember.DateTime` object advanced according the the given parameters.
|
856
856
|
The parameters can be:
|
857
857
|
|
858
|
-
- none, to create a `
|
858
|
+
- none, to create a `Ember.DateTime` instance initialized to the current
|
859
859
|
date and time in the local timezone,
|
860
860
|
- a integer, the number of milliseconds since
|
861
861
|
January, 1st 1970 00:00:00.0 UTC
|
862
862
|
- a options hash that can contain any of the following properties: year,
|
863
863
|
month, day, hour, minute, second, millisecond, timezone
|
864
864
|
|
865
|
-
Note that if you attempt to create a `
|
865
|
+
Note that if you attempt to create a `Ember.DateTime` instance that has already
|
866
866
|
been created, then, for performance reasons, a cached value may be
|
867
867
|
returned.
|
868
868
|
|
@@ -872,7 +872,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
872
872
|
then you should pass a timezone of -120.
|
873
873
|
|
874
874
|
@param options one of the three kind of parameters descibed above
|
875
|
-
@returns {
|
875
|
+
@returns {Ember.DateTime} the Ember.DateTime instance that corresponds to the
|
876
876
|
passed parameters, possibly fetched from cache
|
877
877
|
*/
|
878
878
|
create: function() {
|
@@ -880,7 +880,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
880
880
|
var timezone;
|
881
881
|
|
882
882
|
// if simply milliseconds since Jan 1, 1970 are given, just use those
|
883
|
-
if (
|
883
|
+
if (Ember.typeOf(arg) === 'number') {
|
884
884
|
arg = { milliseconds: arg };
|
885
885
|
}
|
886
886
|
|
@@ -890,7 +890,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
890
890
|
|
891
891
|
// Desired case: create with milliseconds if we have them.
|
892
892
|
// If we don't, convert what we have to milliseconds and recurse.
|
893
|
-
if (!
|
893
|
+
if (!Ember.none(arg.milliseconds)) {
|
894
894
|
|
895
895
|
// quick implementation of a FIFO set for the cache
|
896
896
|
var key = 'nu' + arg.milliseconds + timezone, cache = this._dt_cache;
|
@@ -921,7 +921,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
921
921
|
|
922
922
|
Calls the `create()` method with the current internal `_date` value.
|
923
923
|
|
924
|
-
@return {
|
924
|
+
@return {Ember.DateTime} the Ember.DateTime instance returned by create()
|
925
925
|
*/
|
926
926
|
_createFromCurrentState: function() {
|
927
927
|
return this.create({
|
@@ -931,10 +931,10 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
931
931
|
},
|
932
932
|
|
933
933
|
/**
|
934
|
-
Returns a `
|
934
|
+
Returns a `Ember.DateTime` object created from a given string parsed with a given
|
935
935
|
format. Returns `null` if the parsing fails.
|
936
936
|
|
937
|
-
@see
|
937
|
+
@see Ember.DateTime#toFormattedString for a description of the format parameter
|
938
938
|
@param {String} str the string to parse
|
939
939
|
@param {String} fmt the format to parse the string with
|
940
940
|
@returns {DateTime} the DateTime corresponding to the string parameter
|
@@ -945,7 +945,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
945
945
|
var re = new RegExp('(?:%([aAbBcdDhHiIjmMpsSUWwxXyYZ%])|(.))', "g");
|
946
946
|
var d, parts, opts = {}, check = {}, scanner = Scanner.create({string: str});
|
947
947
|
|
948
|
-
if (
|
948
|
+
if (Ember.none(fmt)) fmt = Ember.DATETIME_ISO8601;
|
949
949
|
|
950
950
|
try {
|
951
951
|
while ((parts = re.exec(fmt)) !== null) {
|
@@ -990,25 +990,25 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
990
990
|
}
|
991
991
|
}
|
992
992
|
} catch (e) {
|
993
|
-
|
993
|
+
Ember.Logger.log('Ember.DateTime.createFromString ' + e.toString());
|
994
994
|
return null;
|
995
995
|
}
|
996
996
|
|
997
|
-
if (!
|
997
|
+
if (!Ember.none(opts.meridian) && !Ember.none(opts.hour)) {
|
998
998
|
if (opts.meridian === 1) opts.hour = (opts.hour + 12) % 24;
|
999
999
|
delete opts.meridian;
|
1000
1000
|
}
|
1001
1001
|
|
1002
|
-
if (!
|
1002
|
+
if (!Ember.none(opts.day) && (opts.day < 1 || opts.day > 31)){
|
1003
1003
|
return null;
|
1004
1004
|
}
|
1005
1005
|
|
1006
1006
|
// Check the month and day are valid and within bounds
|
1007
|
-
if (!
|
1007
|
+
if (!Ember.none(opts.month)){
|
1008
1008
|
if (opts.month < 1 || opts.month > 12){
|
1009
1009
|
return null;
|
1010
1010
|
}
|
1011
|
-
if (!
|
1011
|
+
if (!Ember.none(opts.day)){
|
1012
1012
|
if ( opts.month === 2 && opts.day > 29 ){
|
1013
1013
|
return null;
|
1014
1014
|
}
|
@@ -1020,7 +1020,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
1020
1020
|
|
1021
1021
|
d = this.create(opts);
|
1022
1022
|
|
1023
|
-
if (!
|
1023
|
+
if (!Ember.none(check.dayOfWeek) && get(d,'dayOfWeek') !== check.dayOfWeek) {
|
1024
1024
|
return null;
|
1025
1025
|
}
|
1026
1026
|
|
@@ -1046,7 +1046,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
1046
1046
|
|
1047
1047
|
/**
|
1048
1048
|
@private
|
1049
|
-
@see
|
1049
|
+
@see Ember.DateTime#_toFormattedString
|
1050
1050
|
*/
|
1051
1051
|
__toFormattedString: function(part, start, timezone) {
|
1052
1052
|
var hour, offset;
|
@@ -1101,7 +1101,7 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
1101
1101
|
|
1102
1102
|
/**
|
1103
1103
|
@private
|
1104
|
-
@see
|
1104
|
+
@see Ember.DateTime#toFormattedString
|
1105
1105
|
*/
|
1106
1106
|
_toFormattedString: function(format, start, timezone) {
|
1107
1107
|
var that = this;
|
@@ -1121,8 +1121,8 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
1121
1121
|
comparing their number of milliseconds since
|
1122
1122
|
January, 1st 1970 00:00:00.0 UTC.
|
1123
1123
|
|
1124
|
-
@param {
|
1125
|
-
@param {
|
1124
|
+
@param {Ember.DateTime} a the first DateTime instance
|
1125
|
+
@param {Ember.DateTime} b the second DateTime instance
|
1126
1126
|
@returns {Integer} -1 if a < b,
|
1127
1127
|
+1 if a > b,
|
1128
1128
|
0 if a == b
|
@@ -1138,17 +1138,17 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
1138
1138
|
by only comparing the date parts of the passed objects. Only dates
|
1139
1139
|
with the same timezone can be compared.
|
1140
1140
|
|
1141
|
-
@param {
|
1142
|
-
@param {
|
1141
|
+
@param {Ember.DateTime} a the first DateTime instance
|
1142
|
+
@param {Ember.DateTime} b the second DateTime instance
|
1143
1143
|
@returns {Integer} -1 if a < b,
|
1144
1144
|
+1 if a > b,
|
1145
1145
|
0 if a == b
|
1146
|
-
@throws {
|
1146
|
+
@throws {Ember.DATETIME_COMPAREDATE_TIMEZONE_ERROR} if the passed arguments
|
1147
1147
|
don't have the same timezone
|
1148
1148
|
*/
|
1149
1149
|
compareDate: function(a, b) {
|
1150
1150
|
if (get(a, 'timezone') !== get(b,'timezone')) {
|
1151
|
-
throw new Error(
|
1151
|
+
throw new Error(Ember.DATETIME_COMPAREDATE_TIMEZONE_ERROR);
|
1152
1152
|
}
|
1153
1153
|
|
1154
1154
|
var ma = get(a.adjust({hour: 0}), 'milliseconds');
|
@@ -1162,13 +1162,13 @@ SC.DateTime.reopenClass(SC.Comparable,
|
|
1162
1162
|
Adds a transform to format the DateTime value to a String value according
|
1163
1163
|
to the passed format string.
|
1164
1164
|
|
1165
|
-
valueBinding:
|
1165
|
+
valueBinding: Ember.Binding.dateTime('%Y-%m-%d %H:%M:%S')
|
1166
1166
|
.from('MyApp.myController.myDateTime');
|
1167
1167
|
|
1168
1168
|
@param {String} format format string
|
1169
|
-
@returns {
|
1169
|
+
@returns {Ember.Binding} this
|
1170
1170
|
*/
|
1171
|
-
|
1171
|
+
Ember.Binding.dateTime = function(format) {
|
1172
1172
|
return this.transform(function(value, binding) {
|
1173
1173
|
return value ? value.toFormattedString(format) : null;
|
1174
1174
|
});
|