momentjs_precise_range-rails 1.0.0
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 +7 -0
- data/MIT-LICENSE +22 -0
- data/README.md +25 -0
- data/lib/momentjs_precise_range-rails.rb +7 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +65 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +31 -0
- data/test/dummy/config/environments/production.rb +64 -0
- data/test/dummy/config/environments/test.rb +35 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +10 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/tmp/cache/assets/C59/D90/sprockets%2F125134d272084f1e86b799593b65fa80 +0 -0
- data/test/dummy/tmp/cache/assets/C79/3D0/sprockets%2Fa201672294b3456105e2ecb5a4c95579 +0 -0
- data/test/dummy/tmp/cache/assets/CE5/950/sprockets%2F62738fc554837663c14aeed637ec1a33 +0 -0
- data/test/dummy/tmp/cache/assets/D2E/F50/sprockets%2F3417583dc416d4abf4c2a2da5a5614e4 +0 -0
- data/test/dummy/tmp/cache/assets/D36/D70/sprockets%2Ff48fb163e91f304721712ac5dd8e2c2a +0 -0
- data/test/dummy/tmp/cache/assets/D43/AD0/sprockets%2Fa14586f84b64940f3ed7805e00fad2fe +0 -0
- data/test/dummy/tmp/cache/assets/D6D/350/sprockets%2Fb6ff17db890f0ed05c15d2c6164654fb +0 -0
- data/test/dummy/tmp/cache/assets/D86/E50/sprockets%2F9a1abaa2c6ca6cec85159a7aa3743210 +0 -0
- data/test/dummy/tmp/cache/assets/D9C/A90/sprockets%2Feb33c407156bf38862cb0449dafdf4be +0 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/momentjs_precise_range-rails_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/vendor/assets/javascripts/moment-precise-range.js +122 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e1175392095d7be0ecbfedd8bcc7321c375a53aa
|
4
|
+
data.tar.gz: 1ec701b865cd4a4eb8eadc2feb5302087d18fa3c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ea5b2c8fb677932f04d588ad2cad53002e52606eaeb806be63e83093eeaa9d1bf59b662715a782da7579c539a32d5915821b22034c5b0772c215c9105e9309b
|
7
|
+
data.tar.gz: da9312bc4e56d36dfb548e4d7f45bf9769a950a44d02294ff62d37f40bde0315f047791e7a27efc49e69b65a4c94da9c51161380673b60b10ddf6806f3a0b690
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Chad Johnston
|
4
|
+
moment-precise-range library Copyright (c) 2014 Rob Dawson
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# momentjs_precise_range-rails
|
2
|
+
|
3
|
+
This gem supplies the [moment-precise-range](https://github.com/codebox/moment-precise-range) plugin for use with [momentjs-rails](https://github.com/derekprior/momentjs-rails) in Rails.
|
4
|
+
|
5
|
+
`momentjs-rails` **must** be installed to use this plugin.
|
6
|
+
|
7
|
+
(`momentjs-rails` wraps the [Moment.js](http://momentjs.com/) library in a Rails engine.)
|
8
|
+
|
9
|
+
[moment-precise-range](https://github.com/codebox/moment-precise-range) is a MomentJS plugin for precisely displaying time ranges in a human readable format.
|
10
|
+
|
11
|
+
Moment.js is "a lightweight javascript date library for parsing, manipulating, and formatting dates." Moment.js does not modify the native Date object. Rather, it creates a wrapper for it. Please see the [documentation](http://momentjs.com/docs/) for details.
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Add the following to your gemfile:
|
16
|
+
|
17
|
+
gem 'momentjs_precise_range-rails'
|
18
|
+
|
19
|
+
Add the following directive to your Javascript manifest file (application.js):
|
20
|
+
|
21
|
+
//= require moment-precise-range
|
22
|
+
|
23
|
+
### Acknowledgements
|
24
|
+
|
25
|
+
The content of this repository was heavily ~~stolen~~ borrowed from [momentjs-rails](https://github.com/derekprior/momentjs-rails)
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
# require "active_record/railtie"
|
5
|
+
# require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
# require "active_resource/railtie"
|
8
|
+
require "sprockets/railtie"
|
9
|
+
# require "rails/test_unit/railtie"
|
10
|
+
|
11
|
+
Bundler.require
|
12
|
+
require "momentjs_precise_range-rails"
|
13
|
+
|
14
|
+
module Dummy
|
15
|
+
class Application < Rails::Application
|
16
|
+
# Settings in config/environments/* take precedence over those specified here.
|
17
|
+
# Application configuration should go into files in config/initializers
|
18
|
+
# -- all .rb files in that directory are automatically loaded.
|
19
|
+
|
20
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
21
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
22
|
+
|
23
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
24
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
25
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
26
|
+
|
27
|
+
# Activate observers that should always be running.
|
28
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
29
|
+
|
30
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
31
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
32
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
33
|
+
|
34
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
35
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
36
|
+
# config.i18n.default_locale = :de
|
37
|
+
|
38
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
39
|
+
config.encoding = "utf-8"
|
40
|
+
|
41
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
42
|
+
config.filter_parameters += [:password]
|
43
|
+
|
44
|
+
# Enable escaping HTML in JSON.
|
45
|
+
config.active_support.escape_html_entities_in_json = true
|
46
|
+
|
47
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
48
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
49
|
+
# like if you have constraints or database-specific column types
|
50
|
+
# config.active_record.schema_format = :sql
|
51
|
+
|
52
|
+
# Enforce whitelist mode for mass assignment.
|
53
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
54
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
55
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
56
|
+
# config.active_record.whitelist_attributes = true
|
57
|
+
|
58
|
+
# Enable the asset pipeline
|
59
|
+
config.assets.enabled = true
|
60
|
+
|
61
|
+
# Version of your assets, change this if you want to expire all your assets
|
62
|
+
config.assets.version = '1.0'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
|
26
|
+
# Do not compress assets
|
27
|
+
config.assets.compress = false
|
28
|
+
|
29
|
+
# Expands the lines which load the assets
|
30
|
+
config.assets.debug = true
|
31
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
+
config.serve_static_assets = false
|
13
|
+
|
14
|
+
# Compress JavaScripts and CSS
|
15
|
+
config.assets.compress = true
|
16
|
+
|
17
|
+
# Don't fallback to assets pipeline if a precompiled asset is missed
|
18
|
+
config.assets.compile = false
|
19
|
+
|
20
|
+
# Generate digests for assets URLs
|
21
|
+
config.assets.digest = true
|
22
|
+
|
23
|
+
# Defaults to nil and saved in location specified by config.assets.prefix
|
24
|
+
# config.assets.manifest = YOUR_PATH
|
25
|
+
|
26
|
+
# Specifies the header that your server uses for sending files
|
27
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
28
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
29
|
+
|
30
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
31
|
+
# config.force_ssl = true
|
32
|
+
|
33
|
+
# See everything in the log (default is :info)
|
34
|
+
# config.log_level = :debug
|
35
|
+
|
36
|
+
# Prepend all log lines with the following tags
|
37
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
38
|
+
|
39
|
+
# Use a different logger for distributed setups
|
40
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
41
|
+
|
42
|
+
# Use a different cache store in production
|
43
|
+
# config.cache_store = :mem_cache_store
|
44
|
+
|
45
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
46
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
47
|
+
|
48
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
49
|
+
# config.assets.precompile += %w( search.js )
|
50
|
+
|
51
|
+
# Disable delivery errors, bad email addresses will be ignored
|
52
|
+
# config.action_mailer.raise_delivery_errors = false
|
53
|
+
|
54
|
+
# Enable threaded mode
|
55
|
+
# config.threadsafe!
|
56
|
+
|
57
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
58
|
+
# the I18n.default_locale when a translation can not be found)
|
59
|
+
config.i18n.fallbacks = true
|
60
|
+
|
61
|
+
# Send deprecation notices to registered listeners
|
62
|
+
config.active_support.deprecation = :notify
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
15
|
+
config.whiny_nils = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
config.action_controller.perform_caching = false
|
20
|
+
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
22
|
+
config.action_dispatch.show_exceptions = false
|
23
|
+
|
24
|
+
# Disable request forgery protection in test environment
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
26
|
+
|
27
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
28
|
+
# The :test delivery method accumulates sent emails in the
|
29
|
+
# ActionMailer::Base.deliveries array.
|
30
|
+
config.action_mailer.delivery_method = :test
|
31
|
+
|
32
|
+
|
33
|
+
# Print deprecation notices to the stderr
|
34
|
+
config.active_support.deprecation = :stderr
|
35
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# These inflection rules are supported but not enabled by default:
|
13
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
14
|
+
# inflect.acronym 'RESTful'
|
15
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = '49dfd6e5e224394dc63086a6507249b44ff1ca26e4a474ceb4e57f19aeacc345d514ee349e42e82b7a83d287041cf85487c0753f213534e4dbd02f355202a00b'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json]
|
9
|
+
end
|
10
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
if (typeof moment === "undefined" && require) {
|
2
|
+
moment = require('moment');
|
3
|
+
}
|
4
|
+
|
5
|
+
(function(moment) {
|
6
|
+
var STRINGS = {
|
7
|
+
nodiff: '',
|
8
|
+
year: 'year',
|
9
|
+
years: 'years',
|
10
|
+
month: 'month',
|
11
|
+
months: 'months',
|
12
|
+
day: 'day',
|
13
|
+
days: 'days',
|
14
|
+
hour: 'hour',
|
15
|
+
hours: 'hours',
|
16
|
+
minute: 'minute',
|
17
|
+
minutes: 'minutes',
|
18
|
+
second: 'second',
|
19
|
+
seconds: 'seconds',
|
20
|
+
delimiter: ' '
|
21
|
+
};
|
22
|
+
|
23
|
+
function pluralize(num, word) {
|
24
|
+
return num + ' ' + STRINGS[word + (num === 1 ? '' : 's')];
|
25
|
+
}
|
26
|
+
|
27
|
+
function buildStringFromValues(yDiff, mDiff, dDiff, hourDiff, minDiff, secDiff){
|
28
|
+
var result = [];
|
29
|
+
|
30
|
+
if (yDiff) {
|
31
|
+
result.push(pluralize(yDiff, 'year'));
|
32
|
+
}
|
33
|
+
if (mDiff) {
|
34
|
+
result.push(pluralize(mDiff, 'month'));
|
35
|
+
}
|
36
|
+
if (dDiff) {
|
37
|
+
result.push(pluralize(dDiff, 'day'));
|
38
|
+
}
|
39
|
+
if (hourDiff) {
|
40
|
+
result.push(pluralize(hourDiff, 'hour'));
|
41
|
+
}
|
42
|
+
if (minDiff) {
|
43
|
+
result.push(pluralize(minDiff, 'minute'));
|
44
|
+
}
|
45
|
+
if (secDiff) {
|
46
|
+
result.push(pluralize(secDiff, 'second'));
|
47
|
+
}
|
48
|
+
|
49
|
+
return result.join(STRINGS.delimiter);
|
50
|
+
}
|
51
|
+
|
52
|
+
moment.fn.preciseDiff = function(d2, returnValueObject) {
|
53
|
+
return moment.preciseDiff(this, d2, returnValueObject);
|
54
|
+
};
|
55
|
+
|
56
|
+
moment.preciseDiff = function(d1, d2, returnValueObject) {
|
57
|
+
var m1 = moment(d1), m2 = moment(d2), firstDateWasLater;
|
58
|
+
|
59
|
+
m1.add(m2.utcOffset() - m1.utcOffset(), 'minutes'); // shift timezone of m1 to m2
|
60
|
+
|
61
|
+
if (m1.isSame(m2)) {
|
62
|
+
return STRINGS.nodiff;
|
63
|
+
}
|
64
|
+
if (m1.isAfter(m2)) {
|
65
|
+
var tmp = m1;
|
66
|
+
m1 = m2;
|
67
|
+
m2 = tmp;
|
68
|
+
firstDateWasLater = true;
|
69
|
+
} else {
|
70
|
+
firstDateWasLater = false;
|
71
|
+
}
|
72
|
+
|
73
|
+
var yDiff = m2.year() - m1.year();
|
74
|
+
var mDiff = m2.month() - m1.month();
|
75
|
+
var dDiff = m2.date() - m1.date();
|
76
|
+
var hourDiff = m2.hour() - m1.hour();
|
77
|
+
var minDiff = m2.minute() - m1.minute();
|
78
|
+
var secDiff = m2.second() - m1.second();
|
79
|
+
|
80
|
+
if (secDiff < 0) {
|
81
|
+
secDiff = 60 + secDiff;
|
82
|
+
minDiff--;
|
83
|
+
}
|
84
|
+
if (minDiff < 0) {
|
85
|
+
minDiff = 60 + minDiff;
|
86
|
+
hourDiff--;
|
87
|
+
}
|
88
|
+
if (hourDiff < 0) {
|
89
|
+
hourDiff = 24 + hourDiff;
|
90
|
+
dDiff--;
|
91
|
+
}
|
92
|
+
if (dDiff < 0) {
|
93
|
+
var daysInLastFullMonth = moment(m2.year() + '-' + (m2.month() + 1), "YYYY-MM").subtract(1, 'M').daysInMonth();
|
94
|
+
if (daysInLastFullMonth < m1.date()) { // 31/01 -> 2/03
|
95
|
+
dDiff = daysInLastFullMonth + dDiff + (m1.date() - daysInLastFullMonth);
|
96
|
+
} else {
|
97
|
+
dDiff = daysInLastFullMonth + dDiff;
|
98
|
+
}
|
99
|
+
mDiff--;
|
100
|
+
}
|
101
|
+
if (mDiff < 0) {
|
102
|
+
mDiff = 12 + mDiff;
|
103
|
+
yDiff--;
|
104
|
+
}
|
105
|
+
|
106
|
+
if (returnValueObject) {
|
107
|
+
return {
|
108
|
+
"years" : yDiff,
|
109
|
+
"months" : mDiff,
|
110
|
+
"days" : dDiff,
|
111
|
+
"hours" : hourDiff,
|
112
|
+
"minutes" : minDiff,
|
113
|
+
"seconds" : secDiff,
|
114
|
+
"firstDateWasLater" : firstDateWasLater
|
115
|
+
};
|
116
|
+
} else {
|
117
|
+
return buildStringFromValues(yDiff, mDiff, dDiff, hourDiff, minDiff, secDiff);
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
};
|
122
|
+
}(moment));
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: momentjs_precise_range-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chad Johnston
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.12
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.12
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: |2
|
56
|
+
Supplies the moment-precise-range plugin for use with momentjs-rails in Rails.
|
57
|
+
email: cjohnston@megatome.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- lib/momentjs_precise_range-rails.rb
|
65
|
+
- test/dummy/Rakefile
|
66
|
+
- test/dummy/config.ru
|
67
|
+
- test/dummy/config/application.rb
|
68
|
+
- test/dummy/config/boot.rb
|
69
|
+
- test/dummy/config/environment.rb
|
70
|
+
- test/dummy/config/environments/development.rb
|
71
|
+
- test/dummy/config/environments/production.rb
|
72
|
+
- test/dummy/config/environments/test.rb
|
73
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
74
|
+
- test/dummy/config/initializers/inflections.rb
|
75
|
+
- test/dummy/config/initializers/mime_types.rb
|
76
|
+
- test/dummy/config/initializers/secret_token.rb
|
77
|
+
- test/dummy/config/initializers/session_store.rb
|
78
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
79
|
+
- test/dummy/config/locales/en.yml
|
80
|
+
- test/dummy/config/routes.rb
|
81
|
+
- test/dummy/tmp/cache/assets/C59/D90/sprockets%2F125134d272084f1e86b799593b65fa80
|
82
|
+
- test/dummy/tmp/cache/assets/C79/3D0/sprockets%2Fa201672294b3456105e2ecb5a4c95579
|
83
|
+
- test/dummy/tmp/cache/assets/CE5/950/sprockets%2F62738fc554837663c14aeed637ec1a33
|
84
|
+
- test/dummy/tmp/cache/assets/D2E/F50/sprockets%2F3417583dc416d4abf4c2a2da5a5614e4
|
85
|
+
- test/dummy/tmp/cache/assets/D36/D70/sprockets%2Ff48fb163e91f304721712ac5dd8e2c2a
|
86
|
+
- test/dummy/tmp/cache/assets/D43/AD0/sprockets%2Fa14586f84b64940f3ed7805e00fad2fe
|
87
|
+
- test/dummy/tmp/cache/assets/D6D/350/sprockets%2Fb6ff17db890f0ed05c15d2c6164654fb
|
88
|
+
- test/dummy/tmp/cache/assets/D86/E50/sprockets%2F9a1abaa2c6ca6cec85159a7aa3743210
|
89
|
+
- test/dummy/tmp/cache/assets/D9C/A90/sprockets%2Feb33c407156bf38862cb0449dafdf4be
|
90
|
+
- test/integration/navigation_test.rb
|
91
|
+
- test/momentjs_precise_range-rails_test.rb
|
92
|
+
- test/test_helper.rb
|
93
|
+
- vendor/assets/javascripts/moment-precise-range.js
|
94
|
+
homepage: https://github.com/iamthechad/momentjs_precise_range-rails
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.4.5.1
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: The MomentJS Precise Range plugin in for Rails.
|
118
|
+
test_files:
|
119
|
+
- test/dummy/config/application.rb
|
120
|
+
- test/dummy/config/boot.rb
|
121
|
+
- test/dummy/config/environment.rb
|
122
|
+
- test/dummy/config/environments/development.rb
|
123
|
+
- test/dummy/config/environments/production.rb
|
124
|
+
- test/dummy/config/environments/test.rb
|
125
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
126
|
+
- test/dummy/config/initializers/inflections.rb
|
127
|
+
- test/dummy/config/initializers/mime_types.rb
|
128
|
+
- test/dummy/config/initializers/secret_token.rb
|
129
|
+
- test/dummy/config/initializers/session_store.rb
|
130
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
131
|
+
- test/dummy/config/locales/en.yml
|
132
|
+
- test/dummy/config/routes.rb
|
133
|
+
- test/dummy/config.ru
|
134
|
+
- test/dummy/Rakefile
|
135
|
+
- test/dummy/tmp/cache/assets/C59/D90/sprockets%2F125134d272084f1e86b799593b65fa80
|
136
|
+
- test/dummy/tmp/cache/assets/C79/3D0/sprockets%2Fa201672294b3456105e2ecb5a4c95579
|
137
|
+
- test/dummy/tmp/cache/assets/CE5/950/sprockets%2F62738fc554837663c14aeed637ec1a33
|
138
|
+
- test/dummy/tmp/cache/assets/D2E/F50/sprockets%2F3417583dc416d4abf4c2a2da5a5614e4
|
139
|
+
- test/dummy/tmp/cache/assets/D36/D70/sprockets%2Ff48fb163e91f304721712ac5dd8e2c2a
|
140
|
+
- test/dummy/tmp/cache/assets/D43/AD0/sprockets%2Fa14586f84b64940f3ed7805e00fad2fe
|
141
|
+
- test/dummy/tmp/cache/assets/D6D/350/sprockets%2Fb6ff17db890f0ed05c15d2c6164654fb
|
142
|
+
- test/dummy/tmp/cache/assets/D86/E50/sprockets%2F9a1abaa2c6ca6cec85159a7aa3743210
|
143
|
+
- test/dummy/tmp/cache/assets/D9C/A90/sprockets%2Feb33c407156bf38862cb0449dafdf4be
|
144
|
+
- test/integration/navigation_test.rb
|
145
|
+
- test/momentjs_precise_range-rails_test.rb
|
146
|
+
- test/test_helper.rb
|