moment_timezone-rails 0.0.1.pre → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfd3f6bd2dad15a9b37fd1d1938a62f95e292953
|
4
|
+
data.tar.gz: e09cebf0f117ed1cabee7304caf30f2dfbb6ed2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e27fa57a6a9a55c8f61bcf95ffe6f571726f0e174b682454ffb2a81a7bfbbb8dfe4d0b2a716a60dff26af8baa60a06eabb3e885d658ebc5a6f11fc430251e9a0
|
7
|
+
data.tar.gz: 7926244c38a37f9c584fe86521140384ae43256b299f9d67df3d7f852d7e6a4887fef58a41ac8e2cf2e32d00576e9b4591bf8d16554654fa38f6b86d20de60fe
|
data/README.md
CHANGED
@@ -4,21 +4,39 @@
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
+
Add this line if your application don't have momentjs installed:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'momentjs-rails', '~> 2.1.0'
|
11
|
+
```
|
12
|
+
|
7
13
|
Add this line to your application's Gemfile:
|
8
14
|
|
9
|
-
|
15
|
+
```ruby
|
16
|
+
gem 'moment_timezone-rails'
|
17
|
+
```
|
10
18
|
|
11
19
|
And then execute:
|
12
20
|
|
13
|
-
|
21
|
+
```sh
|
22
|
+
$ bundle
|
23
|
+
```
|
14
24
|
|
15
25
|
Or install it yourself as:
|
16
26
|
|
17
|
-
|
27
|
+
```sh
|
28
|
+
$ gem install moment_timezone-rails
|
29
|
+
```
|
18
30
|
|
19
31
|
## Usage
|
20
32
|
|
21
|
-
|
33
|
+
Add the following directives to `application.js`.
|
34
|
+
|
35
|
+
```js
|
36
|
+
//= require moment
|
37
|
+
//= require moment-timezone
|
38
|
+
//= require moment-timezone-data
|
39
|
+
```
|
22
40
|
|
23
41
|
## Contributing
|
24
42
|
|
@@ -26,4 +44,4 @@ TODO: Write usage instructions here
|
|
26
44
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
45
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
46
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
47
|
+
5. Create new Pull Request
|
@@ -5,7 +5,7 @@ require 'moment_timezone/rails/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "moment_timezone-rails"
|
8
|
-
spec.version =
|
8
|
+
spec.version = MomentTimezone::Rails::VERSION
|
9
9
|
spec.authors = ["Lim Victor"]
|
10
10
|
spec.email = ["github.victor@gmail.com"]
|
11
11
|
spec.description = "moment-timezone for Rails"
|
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency "rails", "~> 3.2.11"
|
22
|
-
spec.add_development_dependency "momentjs-rails", "~> 2.1.0"
|
23
22
|
|
24
23
|
spec.add_runtime_dependency "momentjs-rails", "~> 2.1.0"
|
25
24
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
// moment-timezone.js
|
2
|
-
// version : 0.0.
|
2
|
+
// version : 0.0.2
|
3
3
|
// author : Tim Wood
|
4
4
|
// license : MIT
|
5
5
|
// github.com/timrwood/moment-timezone
|
6
6
|
|
7
7
|
(function () {
|
8
8
|
|
9
|
-
var VERSION = "0.0.
|
9
|
+
var VERSION = "0.0.2";
|
10
10
|
|
11
11
|
function onload(moment) {
|
12
12
|
var oldZoneName = moment.fn.zoneName,
|
@@ -443,6 +443,15 @@
|
|
443
443
|
}
|
444
444
|
};
|
445
445
|
|
446
|
+
function getZoneSets() {
|
447
|
+
var sets = [],
|
448
|
+
zoneName;
|
449
|
+
for (zoneName in zoneSets) {
|
450
|
+
sets.push(zoneSets[zoneName]);
|
451
|
+
}
|
452
|
+
return sets;
|
453
|
+
}
|
454
|
+
|
446
455
|
moment.fn.tz = function (name) {
|
447
456
|
if (name) {
|
448
457
|
this._z = getZoneSet(name);
|
@@ -475,12 +484,16 @@
|
|
475
484
|
for (i = 0; i < len; i++) {
|
476
485
|
args[i] = arguments[i];
|
477
486
|
}
|
478
|
-
|
487
|
+
var m = moment.apply(null, args);
|
488
|
+
var preTzOffset = m.zone();
|
489
|
+
m.tz(arguments[len]);
|
490
|
+
return m.add('minutes', m.zone() - preTzOffset);
|
479
491
|
};
|
480
492
|
|
481
493
|
moment.tz.add = add;
|
482
494
|
moment.tz.addRule = addRule;
|
483
495
|
moment.tz.addZone = addZone;
|
496
|
+
moment.tz.zones = getZoneSets;
|
484
497
|
|
485
498
|
moment.tz.version = VERSION;
|
486
499
|
|
@@ -1 +1 @@
|
|
1
|
-
(function(){function t(t){function n(t){t+="";var e=t.split(":"),n=~t.indexOf("-")?-1:1,s=Math.abs(+e[0]),r=parseInt(e[1],10)||0,i=parseInt(e[2],10)||0;return n*(60*s+r+i/60)}function s(t,e,s,r,i,u,a,o,h,f){this.name=t,this.startYear=+e,this.endYear=+s,this.month=+r,this.day=+i,this.dayRule=+u,this.time=n(a),this.timeRule=+o,this.offset=n(h),this.letters=f||""}function r(t,e){this.rule=e,this.start=e.start(t)}function i(t,e){return t.isLast?-1:e.isLast?1:e.start-t.start}function u(t){this.name=t,this.rules=[]}function a(e,s,r,i,u,a){var o,h="string"==typeof u?u.split("_"):[9999];for(this.name=e,this.offset=n(s),this.ruleSet=r,this.letters=i,o=0;h.length>o;o++)h[o]=+h[o];this.until=t.utc(h).subtract("m",n(a))}function o(t,e){return t.until-e.until}function h(t){this.name=d(t),this.displayName=t,this.zones=[]}function f(t){var e,n,s;for(e in t)for(s=t[e],n=0;s.length>n;n++)l(e+" "+s[n])}function l(t){if(
|
1
|
+
(function(){function t(t){function n(t){t+="";var e=t.split(":"),n=~t.indexOf("-")?-1:1,s=Math.abs(+e[0]),r=parseInt(e[1],10)||0,i=parseInt(e[2],10)||0;return n*(60*s+r+i/60)}function s(t,e,s,r,i,u,a,o,h,f){this.name=t,this.startYear=+e,this.endYear=+s,this.month=+r,this.day=+i,this.dayRule=+u,this.time=n(a),this.timeRule=+o,this.offset=n(h),this.letters=f||""}function r(t,e){this.rule=e,this.start=e.start(t)}function i(t,e){return t.isLast?-1:e.isLast?1:e.start-t.start}function u(t){this.name=t,this.rules=[]}function a(e,s,r,i,u,a){var o,h="string"==typeof u?u.split("_"):[9999];for(this.name=e,this.offset=n(s),this.ruleSet=r,this.letters=i,o=0;h.length>o;o++)h[o]=+h[o];this.until=t.utc(h).subtract("m",n(a))}function o(t,e){return t.until-e.until}function h(t){this.name=d(t),this.displayName=t,this.zones=[]}function f(t){var e,n,s;for(e in t)for(s=t[e],n=0;s.length>n;n++)l(e+" "+s[n])}function l(t){if(Y[t])return Y[t];var e=t.split(/\s/),n=d(e[0]),r=new s(n,e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10]);return Y[t]=r,z(n).add(r),r}function d(t){return(t||"").toLowerCase().replace(/\//g,"_")}function c(t){var e,n,s;for(e in t)for(s=t[e],n=0;s.length>n;n++)p(e+" "+s[n])}function m(t){var e;for(e in t)k[d(e)]=d(t[e])}function p(t){if(M[t])return M[t];var e=t.split(/\s/),n=d(e[0]),s=new a(n,e[1],z(e[2]),e[3],e[4],e[5]);return M[t]=s,y(e[0]).add(s),s}function z(t){return t=d(t),b[t]||(b[t]=new u(t)),b[t]}function y(t){var e=d(t);return k[e]&&(e=k[e]),A[e]||(A[e]=new h(t)),A[e]}function v(t){t&&(t.zones&&c(t.zones),t.rules&&f(t.rules),t.links&&m(t.links))}function R(){var t,e=[];for(t in A)e.push(A[t]);return e}var w,_=t.fn.zoneName,g=t.fn.zoneAbbr,Y={},b={},M={},A={},k={},L=1,N=2,q=7,x=8;return s.prototype={contains:function(t){return t>=this.startYear&&this.endYear>=t},start:function(e){return e=Math.min(Math.max(e,this.startYear),this.endYear),t.utc([e,this.month,this.date(e),0,this.time])},date:function(t){return this.dayRule===q?this.day:this.dayRule===x?this.lastWeekday(t):this.weekdayAfter(t)},weekdayAfter:function(e){for(var n=this.day,s=t([e,this.month,1]).day(),r=this.dayRule+1-s;n>r;)r+=7;return r},lastWeekday:function(e){var n=this.day,s=n%7,r=t([e,this.month+1,1]).day(),i=t([e,this.month,1]).daysInMonth(),u=i+(s-(r-1))-7*~~(n/7);return s>=r&&(u-=7),u}},r.prototype={equals:function(t){return t&&t.rule===this.rule?864e5>Math.abs(t.start-this.start):!1}},u.prototype={add:function(t){this.rules.push(t)},ruleYears:function(t,e){var n,s,u,a=t.year(),o=[];for(n=0;this.rules.length>n;n++)s=this.rules[n],s.contains(a)?o.push(new r(a,s)):s.contains(a+1)&&o.push(new r(a+1,s));return o.push(new r(a-1,this.lastYearRule(a-1))),e&&(u=new r(a-1,e.lastRule()),u.start=e.until.clone().utc(),u.isLast=e.ruleSet!==this,o.push(u)),o.sort(i),o},rule:function(t,e,n){var s,r,i,u,a,o=this.ruleYears(t,n),h=0;for(n&&(r=n.offset+n.lastRule().offset,i=9e4*Math.abs(r)),a=o.length-1;a>-1;a--)u=s,s=o[a],s.equals(u)||(n&&!s.isLast&&i>=Math.abs(s.start-n.until)&&(h+=r-e),s.rule.timeRule===N&&(h=e),s.rule.timeRule!==L&&s.start.add("m",-h),h=s.rule.offset+e);for(a=0;o.length>a;a++)if(s=o[a],t>=s.start&&!s.isLast)return s.rule;return w},lastYearRule:function(t){var e,n,s,r=w,i=-1e30;for(e=0;this.rules.length>e;e++)n=this.rules[e],t>=n.startYear&&(s=n.start(t),s>i&&(i=s,r=n));return r}},a.prototype={rule:function(t,e){return this.ruleSet.rule(t,this.offset,e)},lastRule:function(){return this._lastRule||(this._lastRule=this.rule(this.until)),this._lastRule},format:function(t){return this.letters.replace("%s",t.letters)}},h.prototype={zoneAndRule:function(t){var e,n,s;for(t=t.clone().utc(),e=0;this.zones.length>e&&(n=this.zones[e],!(n.until>t));e++)s=n;return[n,n.rule(t,s)]},add:function(t){this.zones.push(t),this.zones.sort(o)},format:function(t){var e=this.zoneAndRule(t);return e[0].format(e[1])},offset:function(t){var e=this.zoneAndRule(t);return-(e[0].offset+e[1].offset)}},t.updateOffset=function(t){var e;t._z&&(e=t._z.offset(t),16>Math.abs(e)&&(e/=60),t.zone(e))},t.fn.tz=function(e){return e?(this._z=y(e),this._z&&t.updateOffset(this),this):this._z?this._z.displayName:void 0},t.fn.zoneName=function(){return this._z?this._z.format(this):_.call(this)},t.fn.zoneAbbr=function(){return this._z?this._z.format(this):g.call(this)},t.tz=function(){var e,n=[],s=arguments.length-1;for(e=0;s>e;e++)n[e]=arguments[e];var r=t.apply(null,n),i=r.zone();return r.tz(arguments[s]),r.add("minutes",r.zone()-i)},t.tz.add=v,t.tz.addRule=l,t.tz.addZone=p,t.tz.zones=R,t.tz.version=e,w=l("- 0 9999 0 0 0 0 0 0"),t}var e="0.0.2";"function"==typeof define&&define.amd?define("moment-timezone",["moment"],t):"undefined"!=typeof window&&window.moment?t(window.moment):"undefined"!=typeof module&&(module.exports=t(require("moment")))}).apply(this);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moment_timezone-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lim Victor
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.11
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: momentjs-rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 2.1.0
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ~>
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 2.1.0
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: momentjs-rails
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,13 +73,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
73
|
version: '0'
|
88
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
75
|
requirements:
|
90
|
-
- - '
|
76
|
+
- - '>='
|
91
77
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
78
|
+
version: '0'
|
93
79
|
requirements: []
|
94
80
|
rubyforge_project:
|
95
81
|
rubygems_version: 2.0.5
|
96
82
|
signing_key:
|
97
83
|
specification_version: 4
|
98
|
-
summary: moment-timezone-0.0.
|
84
|
+
summary: moment-timezone-0.0.2
|
99
85
|
test_files: []
|