localtime 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/localtime.js.coffee +9 -0
- data/app/helpers/local_time_helper.rb +6 -0
- data/lib/localtime.rb +7 -0
- data/lib/localtime/version.rb +3 -0
- data/localtime.gemspec +28 -0
- data/vendor/assets/javascripts/moment-strftime-0.1.2.js +47 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5a628f7b6865478ac2bcb3b344e611dd1eb1e5a3
|
4
|
+
data.tar.gz: 464a738d6f12948a8c845124cc5ce3a757736a4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4afbbf6ba7775fd7b8830ece55965ff31c32c158e73674b3b78b01546171fdce94e5f5c6afbc91a70d3213f723804d046d9d54565eb3de9dbf1f4af1d4deedd0
|
7
|
+
data.tar.gz: 6edebff24c2acc6e82c0d0a02a43769ef25cc838054180ad5becc2a1058c2eb94ea058126426cac22ac94dfd32821d9b861169aad1c70ddd81227f71adb41d81
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Eric Roberts
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Localtime
|
2
|
+
|
3
|
+
Want to display all your time in the user's local time? Of course you do. Use
|
4
|
+
localtime!
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'localtime'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install localtime
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Localtime is a super simple gem that just takes time tags on your page, reads
|
25
|
+
the strftime attribute if there is one, and updates the text with the user's
|
26
|
+
local time.
|
27
|
+
|
28
|
+
Use it like this:
|
29
|
+
|
30
|
+
``` erb
|
31
|
+
<%= localtime DateTime.now %>
|
32
|
+
```
|
33
|
+
|
34
|
+
Want to pass it some formatting options? Use strftime:
|
35
|
+
|
36
|
+
``` erb
|
37
|
+
<%= localtime DateTime.now, "%Y-%m-%d %H:%M" %>
|
38
|
+
```
|
39
|
+
|
40
|
+
`%Y-%m-%d %H:%M` is the default that will be used if you do not specify
|
41
|
+
anything.
|
42
|
+
|
43
|
+
Enjoy!
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it ( https://github.com/[my-github-username]/localtime/fork )
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/localtime.rb
ADDED
data/localtime.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'localtime/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "localtime"
|
8
|
+
spec.version = Localtime::VERSION
|
9
|
+
spec.authors = ["Boltmade"]
|
10
|
+
spec.email = ["hello@boltmade.com"]
|
11
|
+
spec.summary = %q{Show your users the local time.}
|
12
|
+
spec.description = %q{
|
13
|
+
localtime takes your timestamps and displays them in
|
14
|
+
the end user's local time.
|
15
|
+
}
|
16
|
+
spec.homepage = "https://github.com/Boltmade/localtime"
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0")
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_dependency "railties", ">= 3"
|
27
|
+
spec.add_dependency "momentjs-rails", ">= 0"
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
(function() {
|
2
|
+
var moment, replacements;
|
3
|
+
|
4
|
+
if (typeof require !== "undefined" && require !== null) {
|
5
|
+
moment = require('moment');
|
6
|
+
} else {
|
7
|
+
moment = this.moment;
|
8
|
+
}
|
9
|
+
|
10
|
+
replacements = {
|
11
|
+
a: 'ddd',
|
12
|
+
A: 'dddd',
|
13
|
+
b: 'MMM',
|
14
|
+
B: 'MMMM',
|
15
|
+
d: 'DD',
|
16
|
+
F: 'YYYY-MM-DD',
|
17
|
+
H: 'HH',
|
18
|
+
I: 'hh',
|
19
|
+
j: 'DDDD',
|
20
|
+
m: 'MM',
|
21
|
+
M: 'mm',
|
22
|
+
p: 'A',
|
23
|
+
S: 'ss',
|
24
|
+
Z: 'z',
|
25
|
+
w: 'd',
|
26
|
+
y: 'YY',
|
27
|
+
Y: 'YYYY',
|
28
|
+
'%': '%'
|
29
|
+
};
|
30
|
+
|
31
|
+
moment.fn.strftime = function(format) {
|
32
|
+
var key, momentFormat, value;
|
33
|
+
momentFormat = format;
|
34
|
+
for (key in replacements) {
|
35
|
+
value = replacements[key];
|
36
|
+
momentFormat = momentFormat.replace("%" + key, value);
|
37
|
+
}
|
38
|
+
return this.format(momentFormat);
|
39
|
+
};
|
40
|
+
|
41
|
+
if (typeof module !== "undefined" && module !== null) {
|
42
|
+
module.exports = moment;
|
43
|
+
} else {
|
44
|
+
this.moment = moment;
|
45
|
+
}
|
46
|
+
|
47
|
+
}).call(this);
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: localtime
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Boltmade
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: momentjs-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: "\n localtime takes your timestamps and displays
|
70
|
+
them in\n the end user's local time.\n "
|
71
|
+
email:
|
72
|
+
- hello@boltmade.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- app/assets/javascripts/localtime.js.coffee
|
83
|
+
- app/helpers/local_time_helper.rb
|
84
|
+
- lib/localtime.rb
|
85
|
+
- lib/localtime/version.rb
|
86
|
+
- localtime.gemspec
|
87
|
+
- vendor/assets/javascripts/moment-strftime-0.1.2.js
|
88
|
+
homepage: https://github.com/Boltmade/localtime
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.5
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Show your users the local time.
|
112
|
+
test_files: []
|