date_format 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
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: 3d71ac14f3148f8b713254cea23117f5c7fa6b459513dc51b44f47e66e7f2b09
4
+ data.tar.gz: d25fc58226118e618d7f207f46658f6bcbd95f281dd844569a3e4a4315d39d96
5
5
  SHA512:
6
- metadata.gz: 964426c0bef79366c7702c6b4c1147deceeb678e28f03a602799ab1e477869d1c7f506a8ced9e2b3ec979e0111c3ca099faf23baa4d24bfc59673a35ee23cfd6
7
- data.tar.gz: 9b551225c91f1638df492937b35c05bd120ab3374c6d9dd31d3574969e33b2141b454d5f1435eccb1c4d68e3337ebfa2567ee5bf53c885e092c1cf527434af70
6
+ metadata.gz: 3aaf2e8f26d10a6e45a8099fcc992c12a7de8d40afe676c119d86b91523f9cb804e31ed7efe8b94cbb34f89e6e87732712ec030c349efae027a35da02ecc9fad
7
+ data.tar.gz: 94df45c173c480bc130db315e08c5b16ccc6377f0e574066fdb7c5d40208b9722738d047192c832ce144aaf6e52095b3b94512080d82e05815e785fcdda44170
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")
@@ -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.3
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: ''
@@ -74,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
73
  version: '0'
75
74
  requirements: []
76
75
  rubyforge_project:
77
- rubygems_version: 2.4.5
76
+ rubygems_version: 2.7.7
78
77
  signing_key:
79
78
  specification_version: 4
80
79
  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)