goodtimes 0.2.0 → 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.
data/README.md CHANGED
@@ -20,6 +20,8 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ ### Date/Time Setters
24
+
23
25
  Define some date_time_formats:
24
26
 
25
27
  config/initializers/date_time_formats.rb
@@ -97,6 +99,15 @@ date_attr_writer :date_of_birth, :format => '%m-%d-%Y'
97
99
  date_attr_writer :date_of_birth, :format => Date::DATE_FORMATS[:isdn]
98
100
  ```
99
101
 
102
+ ### Date/Time Format Import
103
+
104
+ In an initializer file:
105
+
106
+ ```ruby
107
+ Goodtimes::DateTimeFormats.import # to import all formats
108
+
109
+ Goodtimes::DateTimeFormats.import :isdn, :timestamp, :timestamp_long # to import 3 specific formats formats
110
+ ```
100
111
 
101
112
  ## Contributing
102
113
 
@@ -1,4 +1,5 @@
1
1
  require "goodtimes/attr_writers"
2
+ require "goodtimes/date_time_formats"
2
3
  require 'goodtimes/railtie'
3
4
  require "goodtimes/version"
4
5
 
@@ -0,0 +1,51 @@
1
+ module Goodtimes
2
+ module DateTimeFormats
3
+
4
+ def self.import( *formats )
5
+ date_time_formats( *formats ).each do |format, pattern|
6
+ Date::DATE_FORMATS.merge!( format => pattern )
7
+ Time::DATE_FORMATS.merge!( format => pattern )
8
+ end
9
+
10
+ time_formats( *formats ).each do |format, pattern|
11
+ Time::DATE_FORMATS.merge!( format => pattern )
12
+ end
13
+ end
14
+
15
+ def self.time_formats( *formats )
16
+ time_formats = {
17
+ :military_time => "%R",
18
+ :military_time_with_zone => "%R %Z",
19
+ }
20
+
21
+ formats.empty? ?
22
+ time_formats :
23
+ time_formats.select { |format, pattern| formats.include?( format ) }
24
+ end
25
+
26
+ def self.date_time_formats( *formats )
27
+ date_time_formats = {
28
+ :isdn => "%Y-%m-%d",
29
+ :isdn_with_time => "%Y-%m-%d %I:%M %p",
30
+ :isdn_with_time_long => "%Y-%m-%d %I:%M:%S %p",
31
+ :timestamp => "%Y%m%d%H%M%S",
32
+ :timestamp_long => "%Y%m%d%H%M%S%L",
33
+ :time_only => "%I:%M:%S %p %Z",
34
+ :us => "%B %d, %Y",
35
+ :us_abbreviated => "%b. %d, %Y",
36
+ :us_abbreviated_with_time => "%b. %d, %Y %I:%M %p",
37
+ :us_abbreviated_with_time_long => "%b. %d, %Y %I:%M:%S %p",
38
+ :us_long => "%B %d, %Y at %I:%M:%S %p",
39
+ :us_long_with_zone => "%B %d, %Y at %I:%M:%S %p %z",
40
+ :us_short => "%m-%d-%Y",
41
+ :us_short_slashed => "%Y/%m/%d",
42
+ :us_slashed_long => "%Y/%m/%d %I:%M:%S"
43
+ }
44
+
45
+ formats.empty? ?
46
+ date_time_formats :
47
+ date_time_formats.select { |format, pattern| formats.include?( format ) }
48
+ end
49
+
50
+ end
51
+ end
@@ -1,3 +1,3 @@
1
1
  module Goodtimes
2
- VERSION = "0.2.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,23 +1,33 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: goodtimes
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - C. Jason Harrelson (midas)
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2013-01-19 00:00:00.000000000 Z
16
+
17
+ date: 2013-03-26 00:00:00 -05:00
18
+ default_executable:
13
19
  dependencies: []
20
+
14
21
  description: Tools for formatting date and time
15
- email:
22
+ email:
16
23
  - jason@lookforwardenterprises.com
17
24
  executables: []
25
+
18
26
  extensions: []
27
+
19
28
  extra_rdoc_files: []
20
- files:
29
+
30
+ files:
21
31
  - .gitignore
22
32
  - Gemfile
23
33
  - LICENSE.txt
@@ -26,30 +36,38 @@ files:
26
36
  - goodtimes.gemspec
27
37
  - lib/goodtimes.rb
28
38
  - lib/goodtimes/attr_writers.rb
39
+ - lib/goodtimes/date_time_formats.rb
29
40
  - lib/goodtimes/railtie.rb
30
41
  - lib/goodtimes/version.rb
42
+ has_rdoc: true
31
43
  homepage: https://github.com/ninja-loss/goodtimes
32
44
  licenses: []
45
+
33
46
  post_install_message:
34
47
  rdoc_options: []
35
- require_paths:
48
+
49
+ require_paths:
36
50
  - lib
37
- required_ruby_version: !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ! '>='
41
- - !ruby/object:Gem::Version
42
- version: '0'
43
- required_rubygems_version: !ruby/object:Gem::Requirement
44
- none: false
45
- requirements:
46
- - - ! '>='
47
- - !ruby/object:Gem::Version
48
- version: '0'
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
49
65
  requirements: []
66
+
50
67
  rubyforge_project:
51
- rubygems_version: 1.8.24
68
+ rubygems_version: 1.3.6
52
69
  signing_key:
53
70
  specification_version: 3
54
71
  summary: Tools for formatting date and time, including some Activerecord extensions.
55
72
  test_files: []
73
+