date_format 0.3.2 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fd52ea155fe83ad311012fce4103b58f2c60487f
4
- data.tar.gz: 3cc8733e8691a93e2f7a5ba9a3ed24c637caab24
2
+ SHA256:
3
+ metadata.gz: 860b7b694ad06379504cc3faec059f22ed2df1c2d9e29f4f7d999a570e4f1e5b
4
+ data.tar.gz: 9206c9d2c51eb1d2ce9107832ca5eb67f8ea024a6ace3360c95ea1159a1898f6
5
5
  SHA512:
6
- metadata.gz: 964426c0bef79366c7702c6b4c1147deceeb678e28f03a602799ab1e477869d1c7f506a8ced9e2b3ec979e0111c3ca099faf23baa4d24bfc59673a35ee23cfd6
7
- data.tar.gz: 9b551225c91f1638df492937b35c05bd120ab3374c6d9dd31d3574969e33b2141b454d5f1435eccb1c4d68e3337ebfa2567ee5bf53c885e092c1cf527434af70
6
+ metadata.gz: 1f43f4b998289ec476a4ff4faa839e5e95c835e79018808e460ea95d3a40c83b5e6ae9f5dad9c6c703dc6bf0c081de343c116950360b9a2b8b50a62dc5183dec
7
+ data.tar.gz: b11600a711a2f07fd9de85bbecc8d390ff269543e24fc491133cf220bce5f22d7c56a6ac7f804fa2aac963b311aa6d1e6fc8e24ccdb621c51ca56e996e41d743
data/README.md CHANGED
@@ -22,28 +22,33 @@ Try this snippet of code on ruby irb
22
22
 
23
23
  require 'date_format'
24
24
  today_time = Time.now
25
- puts DateFormat.change_to(today_time, "GENERAL_DATE") # => 10/11/14 05:12:26 PM
26
- puts DateFormat.change_to(today_time, "LONG_DATE") # => Saturday, October 11, 2014
27
- puts DateFormat.change_to(today_time, "ISO_8601_FORMAT") # => 2014-10-11
28
- puts DateFormat.change_to(today_time, "MEDIUM_DATE") # => 11-Oct-2014
29
- puts DateFormat.change_to(today_time, "SHORT_DATE") # => 10/11/14 (mm/dd/yy)
30
- puts DateFormat.change_to(today_time, "LONG_TIME") # => 05:12:26 PM
31
- puts DateFormat.change_to(today_time, "MEDIUM_TIME") # => 17:12 PM
32
- puts DateFormat.change_to(today_time, "SHORT_TIME") # => 17:12
33
- puts DateFormat.change_to(today_time, "WEEK_OF_YEAR") # => 40
34
- puts DateFormat.change_to(today_time, "DAY_IN_MONTH") # => 11
35
- puts DateFormat.change_to(today_time, "JULIAN_DAY") # => 2014
36
- puts DateFormat.change_to(today_time, "ONLY_HOUR_IN_24HOUR_FORMAT") # => 17
37
- puts DateFormat.change_to(today_time, "HOURS_IN_24HOUR_FORMAT") # => 17:12
38
- puts DateFormat.change_to(today_time, "MINUTE_IN_HOUR") # => 12
39
- puts DateFormat.change_to(today_time, "ONLY_DATE") # => October 11, 2014
40
- puts DateFormat.change_to(today_time, "LONG_DATE_SHORT") # => Sat, October 11, 2014
41
- puts DateFormat.change_to(today_time, "ONLY_DATE_DEFAULT") # => 11/10/2014 (dd/mm/yy)
42
- puts DateFormat.change_to(today_time, "ONLY_DATE_SHORT") # => Oct 11, 2014
43
- puts DateFormat.change_to(today_time, "ONLY_DATE_SHORTEST") # => Sat, Oct 11, 2014
44
- puts DateFormat.change_to(today_time, "") # => 11.10.14
45
- puts DateFormat.change_to("", "") # => NA
46
-
25
+ puts DateFormat.change_to(today_time, "GENERAL_DATE") # => 10/11/14 05:12:26 PM
26
+ puts DateFormat.change_to(today_time, "LONG_DATE") # => Saturday, October 11, 2014
27
+ puts DateFormat.change_to(today_time, "ISO_8601_FORMAT") # => 2014-10-11
28
+ puts DateFormat.change_to(today_time, "MEDIUM_DATE") # => 11-Oct-2014
29
+ puts DateFormat.change_to(today_time, "SHORT_DATE") # => 10/11/14 (mm/dd/yy)
30
+ puts DateFormat.change_to(today_time, "LONG_TIME") # => 05:12:26 PM
31
+ puts DateFormat.change_to(today_time, "MEDIUM_TIME") # => 17:12 PM
32
+ puts DateFormat.change_to(today_time, "SHORT_TIME") # => 17:12
33
+ puts DateFormat.change_to(today_time, "WEEK_OF_YEAR") # => 40
34
+ puts DateFormat.change_to(today_time, "DAY_IN_MONTH") # => 11
35
+ puts DateFormat.change_to(today_time, "JULIAN_DAY") # => 2014
36
+ puts DateFormat.change_to(today_time, "ONLY_HOUR_IN_24HOUR_FORMAT") # => 17
37
+ puts DateFormat.change_to(today_time, "HOURS_IN_24HOUR_FORMAT") # => 17:12
38
+ puts DateFormat.change_to(today_time, "MINUTE_IN_HOUR") # => 12
39
+ puts DateFormat.change_to(today_time, "ONLY_DATE") # => October 11, 2014
40
+ puts DateFormat.change_to(today_time, "LONG_DATE_SHORT") # => Sat, October 11, 2014
41
+ puts DateFormat.change_to(today_time, "ONLY_DATE_DEFAULT") # => 11/10/2014 (dd/mm/yy)
42
+ puts DateFormat.change_to(today_time, "ONLY_DATE_SHORT") # => Oct 11, 2014
43
+ puts DateFormat.change_to(today_time, "ONLY_DATE_SHORTEST") # => Sat, Oct 11, 2014
44
+ puts DateFormat.change_to(today_time, "") # => 11.10.14
45
+ puts DateFormat.change_to(today_time, "ONLY_CURRENT_DATE_NUMBER") # => 11
46
+ puts DateFormat.change_to(today_time, "ONLY_CURRENT_DATE_ALPHABET") # => Sat
47
+ puts DateFormat.change_to(today_time, "ONLY_CURRENT_MONTH_NUMBER") # => 10
48
+ puts DateFormat.change_to(today_time, "ONLY_CURRENT_MONTH_ALPHABET") # => Oct
49
+ puts DateFormat.change_to(today_time, "ONLY_CURRENT_YEAR_MONTH") # => 201410
50
+ puts DateFormat.change_to("", "") # => NA
51
+
47
52
  # For Time Difference
48
53
  start_date = Time.parse('2014-05-25 18:37:11')
49
54
  DateFormat.time_difference(start_date, "PRESENT_DAY", "DAY_ONLY")
@@ -13,7 +13,7 @@ module DateFormat
13
13
  end
14
14
 
15
15
  def self.choose_date_format(format_type)
16
- case format_type
16
+ case format_type
17
17
  when "ISO_8601_FORMAT" # => 2014-05-15
18
18
  "%F"
19
19
  when "GENERAL_DATE" # => 4/3/93 05:34:00 PM
@@ -62,6 +62,8 @@ module DateFormat
62
62
  "%b"
63
63
  when "ONLY_CURRENT_YEAR_MONTH" # => 201404 ***
64
64
  "%Y%m"
65
+ when 'MYSQL_QUERY_FORMAT'
66
+ "%Y-%m-%d %H:%M:%S.%6N"
65
67
  else
66
68
  "%d.%m.%y"
67
69
  end
@@ -89,11 +91,11 @@ module DateFormat
89
91
  end
90
92
 
91
93
  def self.choose_time_difference_format(time_difference_in_second, days, hours, minutes, seconds, format_type)
92
- case format_type
93
-
94
+ case format_type
95
+
94
96
  when "DAY_ONLY"
95
97
  "#{days} Days"
96
-
98
+
97
99
  when "HOUR_ONLY"
98
100
  begin
99
101
  only_hours = (time_difference_in_second/3600).round(2)
@@ -119,12 +121,12 @@ module DateFormat
119
121
 
120
122
 
121
123
  def self.day_difference(start_date, end_date)
122
- formatted_time = ""
124
+ formatted_time = ""
123
125
  end_date = Time.now if end_date == 'PRESENT_DAY'
124
126
  time_difference_in_second = (end_date - start_date).to_i
125
127
  rest, seconds = time_difference_in_second.divmod( 60 )
126
128
  rest, minutes = rest.divmod( 60 )
127
- days, hours = rest.divmod( 24 )
129
+ days, hours = rest.divmod( 24 )
128
130
 
129
131
  if days > 0
130
132
  tag = (days < 2) ? "day" : "days"
@@ -1,3 +1,3 @@
1
1
  module DateFormat
2
- VERSION = "0.3.2"
2
+ VERSION = '0.3.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date_format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahul Patil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2018-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -51,7 +51,6 @@ files:
51
51
  - README.md
52
52
  - Rakefile
53
53
  - lib/date_format.rb
54
- - lib/date_format/TestFile.txt
55
54
  - lib/date_format/base.rb
56
55
  - lib/date_format/version.rb
57
56
  homepage: ''
@@ -73,8 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
72
  - !ruby/object:Gem::Version
74
73
  version: '0'
75
74
  requirements: []
76
- rubyforge_project:
77
- rubygems_version: 2.4.5
75
+ rubygems_version: 3.4.10
78
76
  signing_key:
79
77
  specification_version: 4
80
78
  summary: Date Format
@@ -1,126 +0,0 @@
1
- def duration(timenow, )
2
- secs = timenow.to_i
3
- mins = secs / 60
4
- hours = mins / 60
5
- days = hours / 24
6
-
7
-
8
-
9
- if days > 0
10
- "#{days} days and #{hours % 24} hours"
11
- elsif hours > 0
12
- "#{hours} hours and #{mins % 60} minutes"
13
- elsif mins > 0
14
- "#{mins} minutes and #{secs % 60} seconds"
15
- elsif secs >= 0
16
- "#{secs} seconds"
17
- end
18
- end
19
-
20
- def day_difference(start_date, end_date)
21
- end_date = Time.now if end_date == 'PRESENT_DAY'
22
- puts "END Date = #{end_date}"
23
- difference = (end_date - start_date).to_i
24
- puts "difference = #{difference}"
25
- seconds = difference / 60
26
- minutes = seconds / 60
27
- hours = minutes / 60
28
- days = hours / 24
29
- puts "Days : #{days}, Hours : #{hours}, Minutes : #{minutes}, Seconds : #{seconds}"
30
- output = ""
31
- output += "#{days} days" if days > 0
32
- puts "Output1 : #{output}"
33
- output += "#{hours % 24} hours" if hours > 0
34
- puts "Output2 : #{output}"
35
- output += "#{minutes % 60} minutes" if minutes > 0
36
- puts "Output3 : #{output}"
37
- output += "#{seconds % 60} seconds" if seconds > 0
38
- puts "Output4 : #{output}"
39
-
40
- puts output
41
- end
42
-
43
-
44
-
45
-
46
-
47
-
48
- def self.day_difference(start_date, PRESENT_DAY)
49
- def self.day_difference(start_date, PRESENT_DAY)
50
-
51
- def time_difference(start_date, end_time, '') // CompleteDateTime
52
- def time_difference(start_date, end_time, 'ONLY_DAY')
53
- def time_difference(start_date, end_time, 'ONLY_HOURS')
54
-
55
-
56
-
57
-
58
- //def time_difference(start_date, end_time, 'ONLY_MINUTES')
59
- //def time_difference(start_date, end_time, 'ONLY_SECONDS')
60
-
61
- def day_difference(start_date, end_date)
62
- end_date = Time.now if end_date == 'PRESENT_DAY'
63
- puts "END Date = #{end_date}"
64
- difference = (end_date - start_date).to_i
65
- puts "difference = #{difference}"
66
- days = 0
67
- hours = difference/3600
68
- minutes = (difference/60)%60
69
- seconds = difference%60
70
- puts "Days : #{days}, Hours : #{hours}, Minutes : #{minutes}, Seconds : #{seconds}"
71
- output = ""
72
- output += "#{days} days" if days > 0
73
- puts "Output1 : #{output}"
74
- output += "#{hours % 24} hours" if hours > 0
75
- puts "Output2 : #{output}"
76
- output += "#{minutes % 60} minutes" if minutes > 0
77
- puts "Output3 : #{output}"
78
- output += "#{seconds % 60} seconds" if seconds > 0
79
- puts "Output4 : #{output}"
80
- puts output
81
- end
82
-
83
-
84
- rest, secs = self.divmod( 60 )
85
- rest, mins = rest.divmod( 60 )
86
- days, hours = rest.divmod( 24 )
87
- [days, hours, mins, secs]
88
-
89
- require 'time'
90
- def day_difference(start_date, end_date)
91
- end_date = Time.now if end_date == 'PRESENT_DAY'
92
- time_difference_in_second = (end_date - start_date).to_i
93
- rest, seconds = time_difference_in_second.divmod( 60 )
94
- rest, minutes = rest.divmod( 60 )
95
- days, hours = rest.divmod( 24 )
96
- output = ""
97
- output += "#{days} days" if days > 0
98
- output += "#{hours} hours" if hours > 0
99
- output += "#{minutes} minutes" if minutes > 0
100
- output += "#{seconds} seconds" if seconds > 0
101
- puts output
102
- end
103
-
104
-
105
- require 'date_format'
106
- start_date = Time.parse('2014-05-25 18:37:11')
107
- DateFormat.time_difference(start_date, "PRESENT_DAY", "DAY_ONLY")
108
- DateFormat.time_difference(start_date, "PRESENT_DAY", "HOUR_ONLY")
109
- DateFormat.time_difference(start_date, "PRESENT_DAY", "MINUTE_ONLY")
110
- DateFormat.time_difference(start_date, "PRESENT_DAY", "SECOND_ONLY")
111
- DateFormat.time_difference(start_date, "", "DAY_ONLY")
112
- DateFormat.time_difference(start_date, "", "HOUR_ONLY")
113
- DateFormat.time_difference(start_date, "", "MINUTE_ONLY")
114
- DateFormat.time_difference(start_date, "", "SECOND_ONLY")
115
- DateFormat.time_difference(start_date, "AA", "DAY_ONLY")
116
- DateFormat.time_difference(start_date, "AA", "HOUR_ONLY")
117
- DateFormat.time_difference(start_date, "XX", "MINUTE_ONLY")
118
- DateFormat.time_difference(start_date, "DD", "SECOND_ONLY")
119
-
120
- 2.0.0-p353 :002 > start_date = Time.parse('2014-05-25 18:37:11')
121
- => 2014-05-25 18:37:11 +0530
122
- 2.0.0-p353 :003 > puts DateFormat.day_difference(start_date, "PRESENT_DAY")
123
-
124
-
125
- # FORMAT => DAY_ONLY, HOUR_ONLY, MINUTE_ONLY, SECOND_ONLY
126
- def time_difference(start_date, end_date, format_type)