date_format 0.0.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.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in date_format.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # DateFormat
2
+
3
+ DateFormat is the gem used to access formatted datetime.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'date_format'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install date_format
18
+
19
+ ## Usage
20
+
21
+ Try this snippet of code on ruby console by using irb
22
+
23
+ require 'date_format'
24
+ today_time = Time.now
25
+ puts DateFormat.change_to(today_time, "GENERAL_DATE") # => 05/15/14 01:22:29 PM
26
+ puts DateFormat.change_to(today_time, "LONG_DATE") # => Thursday, May 15, 2014
27
+ puts DateFormat.change_to(today_time, "ISO_8601_FORMAT") # => 2014-05-15
28
+
29
+ puts DateFormat.change_to(today_time, "MEDIUM_DATE") # => 15-May-2014
30
+ puts DateFormat.change_to(today_time, "SHORT_DATE") # => 05/15/14
31
+ puts DateFormat.change_to(today_time, "LONG_TIME") # => 01:22:29 PM
32
+ puts DateFormat.change_to(today_time, "MEDIUM_TIME") # => 13:22 PM
33
+ puts DateFormat.change_to(today_time, "SHORT_TIME") # => 13:22
34
+ puts DateFormat.change_to(today_time, "WEEK_OF_YEAR") # => 19
35
+ puts DateFormat.change_to(today_time, "DAY_IN_MONTH") # => 15
36
+ puts DateFormat.change_to(today_time, "JULIAN_DAY") # => 2014
37
+ puts DateFormat.change_to(today_time, "ONLY_HOUR_IN_24HOUR_FORMAT") # => 13 Hour
38
+ puts DateFormat.change_to(today_time, "HOURS_IN_24HOUR_FORMAT") # => 13:34 Hour:Minute
39
+ puts DateFormat.change_to(today_time, "MINUTE_IN_HOUR") # => 34 Minute
40
+
41
+ puts DateFormat.change_to(today_time, "")
42
+ puts DateFormat.change_to("", "")
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it ( https://github.com/[my-github-username]/date_format/fork )
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,2 @@
1
+ require_relative './date_format/base.rb'
2
+ require_relative './date_format/version.rb'
@@ -0,0 +1,49 @@
1
+ module DateFormat
2
+
3
+ def self.change_to(element, format_type)
4
+ begin
5
+ unless element.nil? || element == ""
6
+ element.strftime(choose_date_format(format_type))
7
+ else
8
+ "NA"
9
+ end
10
+ rescue
11
+ element
12
+ end
13
+ end
14
+
15
+ def self.choose_date_format(format_type)
16
+ case format_type
17
+ when "ISO_8601_FORMAT" # => 2014-05-15
18
+ "%F"
19
+ when "GENERAL_DATE" # => 4/3/93 05:34:00 PM
20
+ "%m/%d/%y %r"
21
+ when "LONG_DATE" # => Saturday, April 3, 2014
22
+ "%A, %B %d, %Y"
23
+ when "MEDIUM_DATE" # => 3-Apr-2014
24
+ "%d-%b-%Y"
25
+ when "SHORT_DATE" # => 4/3/93
26
+ "%D"
27
+ when "LONG_TIME" # => 5:34:23 PM
28
+ "%r"
29
+ when "MEDIUM_TIME" # => 5:34 PM
30
+ "%H:%M %p"
31
+ when "SHORT_TIME" # => 17:34
32
+ "%H:%M"
33
+ when "WEEK_OF_YEAR" # => 19
34
+ "%W"
35
+ when "DAY_IN_MONTH" # => 3
36
+ "%d"
37
+ when "JULIAN_DAY" # => 2014
38
+ "%G"
39
+ when "ONLY_HOUR_IN_24HOUR_FORMAT" # => 13 Hour
40
+ "%H"
41
+ when "HOURS_IN_24HOUR_FORMAT" # => 13:34 Hour:Minute
42
+ "%H:%M"
43
+ when "MINUTE_IN_HOUR" # => 34 Minute
44
+ "%M"
45
+ else
46
+ "%d.%m.%y"
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module DateFormat
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: date_format
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Rahul Patil
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-05-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.6'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: The library take raw date as input and adds a method to give formatted
47
+ date.
48
+ email:
49
+ - rahupatil_scs@yahoo.co.in
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - README.md
55
+ - Gemfile
56
+ - Rakefile
57
+ - lib/date_format/base.rb
58
+ - lib/date_format/version.rb
59
+ - lib/date_format.rb
60
+ homepage: ''
61
+ licenses:
62
+ - MIT
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 1.8.24
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Date Format
85
+ test_files: []