date_convert 0.1.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bb29b872153f56eabfd47cba7da0ccf4c1179cc6
4
+ data.tar.gz: dbbca9fcf73ecd8b58a39ad4a1a40aaf4d69e09d
5
+ SHA512:
6
+ metadata.gz: ecdcf17ae633ba1845e913fff64153fa98f6c91f50c6d15de4bdf7eb20bb95b21ab79f553fce1613b2fe7c48934be8d44d06852f95323d1017aa14a24e18cd7f
7
+ data.tar.gz: 96c40b4ffef6bc4fade751669ee8f80b21d11aaffb44ee147153005aff1eef1d667dc4520e79ef096feca2ca8bf0278120134e31e3c7bd165759273dd91566d5
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at cmiklius@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in date_convert.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Chris Miklius
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # DateConvert
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/date_convert`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'date_convert'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install date_convert
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/date_convert. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "date_convert"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -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 'date_convert/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "date_convert"
8
+ spec.version = DateConvert::VERSION
9
+ spec.authors = ["Chris Miklius"]
10
+ spec.email = ["cmiklius@gmail.com"]
11
+
12
+ spec.summary = %q{Convert dates to ISO 8601 format}
13
+ spec.description = %q{Convert dates to ISO 8601 format}
14
+ spec.homepage = "https://github.com/ChrisMIX/CodeFoo6Application/tree/master/date_convert"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.11"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
@@ -0,0 +1,7 @@
1
+ require "../lib/date_convert/version.rb"
2
+ require "..lib/date_convert/fix_date.rb"
3
+ module DateConvert
4
+
5
+ end
6
+
7
+ puts DateConvert::fix_that_date("3/20/2016")
@@ -0,0 +1,244 @@
1
+ class String
2
+ def fix_that_date()
3
+
4
+ months = {"January" => "01",
5
+ "JAN" => "01",
6
+ "Jan" => "01",
7
+ "February" => "02",
8
+ "FEB" => "02",
9
+ "Feb" => "02",
10
+ "March" => "03",
11
+ "MAR" => "03",
12
+ "Mar" => "03",
13
+ "April" => "04",
14
+ "APR" => "04",
15
+ "Apr" => "04",
16
+ "May" => "05",
17
+ "June" => "06",
18
+ "JUN" => "06",
19
+ "Jun" => "06",
20
+ "July" => "07",
21
+ "JUL" => "07",
22
+ "Jul" => "07",
23
+ "August" => "08",
24
+ "AUG" => "08",
25
+ "Aug" => "08",
26
+ "September" => "09",
27
+ "SEPT" => "09",
28
+ "Sept" => "09",
29
+ "October" => "10",
30
+ "OCT" => "10",
31
+ "Oct" => "10",
32
+ "November" => "11",
33
+ "NOV" => "11",
34
+ "Nov" => "11",
35
+ "December" => "12",
36
+ "DEC" => "12",
37
+ "Dec" => "12"}
38
+
39
+ #3/20/2016 4:05:07 PM
40
+ if /(\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}:\d{2}:\d{2} (AM|PM))/.match(self).nil? == false
41
+ date = ""
42
+ new_date = self
43
+ new_date = new_date.split(" ")
44
+
45
+ date << new_date[0][-4..-1] + "-"
46
+
47
+ if new_date[0][1] == "/"
48
+ date << "0" + new_date[0][0] + "-" + new_date[0][2..3] + "-"
49
+ else
50
+ date << new_date[0][0..1] + "-" + new_date[0][3..4]
51
+ end
52
+
53
+ date << "T" + new_date[1] + ".000Z"
54
+
55
+ #2016-20-03T16:05:07-08:00
56
+ elsif /(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}-\d{2}:\d{2})/.match(self).nil? == false
57
+ date = self
58
+ day = date[5..6]
59
+ month = date[8..9]
60
+
61
+ date[5..6] = month
62
+ date[8..9] = day
63
+
64
+
65
+ #3/20/2016 4:05 PM
66
+ elsif /(\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}:\d{2} (AM|PM))/.match(self).nil? == false
67
+ date = ""
68
+ new_date = self
69
+ new_date = new_date.split(" ")
70
+ date << new_date[0][-4..-1] + "-"
71
+
72
+ if new_date[0][1] == "/"
73
+ date << "0" + new_date[0][0] + "-" + new_date[0][2..3] + "-"
74
+ else
75
+ date << new_date[0][0..1] + "-" + new_date[0][3..4]
76
+ end
77
+
78
+ date << "T" + new_date[1] + ":00.000Z"
79
+
80
+ #20/03/2016
81
+ elsif /(\d{2}\/\d{2}\/\d{4})/.match(self).nil? == false && self[0..1].to_i > 12
82
+ date = ""
83
+ new_date = self
84
+ date << new_date[-4..-1] + "-" + new_date[-7..-6] + "-"
85
+
86
+ if new_date[1] == "/"
87
+ date << "0" + new_date[0]
88
+ else
89
+ date << new_date[0..1]
90
+ end
91
+
92
+ #3/20/2016
93
+ elsif /(\d{1,2}\/\d{2}\/\d{4})/.match(self).nil? == false
94
+ date = self
95
+ date = date.prepend("0") << "/"
96
+ last_five = date[6..10]
97
+ date = date[1..4].prepend(last_five).gsub!(/\//, "-")
98
+
99
+ #Sunday, MAR 20, 2016
100
+ elsif /([a-zA-Z]{5,9}, [a-zA-Z]{3} \d{1,2}, \d{4})/.match(self).nil? == false
101
+
102
+ date = ""
103
+ new_date = self
104
+ new_date = new_date.split(" ")
105
+ date << new_date[3] + "-" + months[new_date[1]] + "-" + new_date[2][0..1]
106
+
107
+
108
+
109
+ #Sunday 20th of March 2016 04:05:07 PM
110
+ elsif /([a-zA-Z]{5,9} \d{1,2}[a-zA-Z]{2} of [a-zA-Z]{3,9} \d{4} \d{2}:\d{2}:\d{2} (AM|PM))/.match(self).nil? == false
111
+ date = ""
112
+ new_date = self
113
+ time = new_date[-11..-4] + ".000Z"
114
+ new_date = new_date.split(" ")
115
+
116
+ date << new_date[4] + "-" + months[new_date[3]] + "-" + new_date[1][0..1] + "T" + time
117
+
118
+ #Sunday, March 20, 2016 4:05:07 PM
119
+ elsif (/([a-zA-Z]{5,9}\, [a-zA-Z]{5,9} \d{1,2}, \d{4})/.match(self).nil? == false) && (/(\d{1,2}\:\d{2}\:\d{2}\ (AM|PM))/.match(self).nil? == false)
120
+
121
+ date = ""
122
+ new_date = self
123
+ newest_date = /([a-zA-Z]{5,9}\, [a-zA-Z]{5,9} \d{1,2}, \d{4})/.match(self)[0][-14..-1]
124
+
125
+ newest_date2 = newest_date.split(" ")
126
+ date << newest_date[-4..-1] + "-" + months[newest_date2[0]] + "-" + newest_date2[1][0..1] + "T"
127
+
128
+ time = new_date[-11..-1]
129
+
130
+ if time[0] != " "
131
+ time = time[0..7].prepend("0") << ".000"
132
+ else
133
+ time = time[1..7].prepend("0") << ".000"
134
+ end
135
+
136
+ date << time + "Z"
137
+
138
+ #Sunday, March 20, 2016 4:05 PM
139
+ elsif (/([a-zA-Z]{5,9}\, [a-zA-Z]{5,9} \d{1,2}, \d{4})/.match(self).nil? == false) && (/(\d{1,2}\:\d{2}\ (AM|PM))/.match(self).nil? == false)
140
+ date = ""
141
+ new_date = self
142
+ newest_date = /([a-zA-Z]{5,9}\, [a-zA-Z]{5,9} \d{1,2}, \d{4})/.match(self)[0][-14..-1]
143
+
144
+ newest_date2 = newest_date.split(" ")
145
+ date << newest_date[-4..-1] + "-" + months[newest_date2[0]] + "-" + newest_date2[1][0..1] + "T"
146
+
147
+ time = new_date[-7..-1]
148
+
149
+ if time[0] != " "
150
+ time = time[0..7].prepend("0") << ":00.000"
151
+ else
152
+ time = time[1..7].prepend("0") << ":00.000"
153
+ end
154
+
155
+ date << time + "Z"
156
+
157
+ #4:05:07 PM
158
+ elsif /(\d{1}\:\d{2}\:\d{2}\ (AM|PM))/.match(self).nil? == false || /(\d{2}\:\d{2}\:\d{2}\ (AM|PM))/.match(self).nil? == false
159
+ date = self
160
+ date = date[0..6].prepend("0") << ".000"
161
+
162
+ #Sunday, March 20, 2016
163
+ elsif /([a-zA-Z]{5,9}\, [a-zA-Z]{5,9} \d{1,2}, \d{4})/.match(self).nil? == false
164
+ date = ""
165
+ new_date = self
166
+ new_date = new_date[-14..-1]
167
+ newer_date = new_date.split(" ")
168
+ date << new_date[-4..-1] + "-" + months[newer_date[0]] + "-" + newer_date[1][0..1]
169
+
170
+ #March 20, 2016
171
+ elsif /([a-zA-Z]{3,9} \d{1,2}, \d{4})/.match(self).nil? == false
172
+
173
+ date = ""
174
+ new_date = self
175
+ new_date = new_date.split(" ")
176
+ date << new_date[2] + "-" + months[new_date[0]] + "-" + new_date[1][0..1]
177
+
178
+ #Sun, 20 Mar 2016 16:05:07 GMT
179
+ elsif /([a-zA-Z]{3}, \d{1,2} [a-zA-Z]{3} \d{4} \d{2}:\d{2}:\d{2} [a-zA-Z]{3})/.match(self).nil? == false
180
+ date = ""
181
+ new_date = self
182
+ new_date = new_date.split(" ")
183
+
184
+ date << new_date[3] + "-" + months[new_date[2]] + "-" + new_date[1] + "T" + new_date[4] + "+00:00"
185
+
186
+ #Sun, 20 Mar 2016 16:05:07 -0800
187
+ elsif /([a-zA-Z]{3}, \d{1,2} [a-zA-Z]{3} \d{4} \d{2}:\d{2}:\d{2} -\d{4})/.match(self).nil? == false
188
+ date = ""
189
+ new_date = self
190
+ new_date = new_date.split(" ")
191
+ date << new_date[3] + "-" + months[new_date[2]] + "-" + new_date[1] + "T" + new_date[4] + new_date[5][0] + new_date[5][1..2] + ":" + new_date[5][3..4]
192
+
193
+ #March, 2016
194
+ elsif /([a-zA-Z]{3,9}, \d{4})/.match(self).nil? == false
195
+ date = ""
196
+ new_date = self
197
+ new_date = new_date.split(" ")
198
+
199
+ date << new_date[1] + "-"
200
+ date << months[new_date[0].delete ","]
201
+
202
+ #20160320 16:05:07
203
+ elsif /(\d{8} \d{2}:\d{2}:\d{2})/.match(self).nil? == false
204
+ date = ""
205
+ new_date = self
206
+ new_date = new_date.split(" ")
207
+
208
+ date << new_date[0]
209
+ date = date.insert(4, "-").insert(7, "-")
210
+ date = date + "T" + new_date[1] + "Z"
211
+
212
+ #20160320
213
+ elsif /(\d{8})/.match(self).nil? == false
214
+ date = self
215
+ date.insert(4,"-").insert(7, "-")
216
+
217
+ #20 March 2016
218
+ elsif /(\d{2} [a-zA-Z]{3,9} \d{4})/.match(self).nil? == false
219
+ date = ""
220
+ new_date = self
221
+ new_date = new_date.split(" ")
222
+ date << new_date[2] + "-" + months[new_date[1]] + "-" + new_date[0]
223
+
224
+ #2016.03.20
225
+ elsif /(\d{4}.\d{2}.\d{2})/.match(self).nil? == false
226
+ date = self
227
+ date[4] = "-"
228
+ date[7] = "-"
229
+
230
+
231
+ #March 20
232
+ elsif /([a-zA-Z]{3,9} \d{1,2})/.match(self).nil? == false
233
+ date = ""
234
+ new_date = self
235
+ new_date = new_date.split(" ")
236
+
237
+ date << "2016-" + months[new_date[0]] + "-" + new_date[1]
238
+
239
+ else
240
+ puts "It appears this time format is not supported."
241
+ end
242
+ date
243
+ end
244
+ end
@@ -0,0 +1,3 @@
1
+ module DateConvert
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: date_convert
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Miklius
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-17 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
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: rspec
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: Convert dates to ISO 8601 format
56
+ email:
57
+ - cmiklius@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - date_convert.gemspec
73
+ - lib/date_convert.rb
74
+ - lib/date_convert/fix_date.rb
75
+ - lib/date_convert/version.rb
76
+ homepage: https://github.com/ChrisMIX/CodeFoo6Application/tree/master/date_convert
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.5
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Convert dates to ISO 8601 format
100
+ test_files: []