time-helper 1.0 → 1.0.01

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.
Files changed (2) hide show
  1. data/README +33 -0
  2. metadata +2 -1
data/README ADDED
@@ -0,0 +1,33 @@
1
+ This gem adds a few methods to Time, both instance and class.
2
+ It's not great, but makes my life easier on a few cucumber based projects.
3
+ There's a method Time.strtotime which takes a date(time) string and turns it into a time object.
4
+ Also method add and substract to the instance. (Important, these methods do not account for leap years and months, etc, one month is 30 days and 1 year is 365 days.)
5
+
6
+ Usage examples:
7
+
8
+ Time.strtotime date_string
9
+
10
+ | date string | resulting time object |
11
+ | 24-12-2011 | Time.local(2011,12,24) |
12
+ | 2011-12-24 | Time.local(2011,12,24) |
13
+ | 24/12/2011 | Time.local(2011,12,24) |
14
+ | 2011/12/24 | Time.local(2011,12,24) |
15
+ | 24122011 | Time.local(2011,12,24) |
16
+ | 20111224 | Time.local(2011,12,24) |
17
+ | 30042012 | Time.local(2012,04,30) |
18
+ | 20120430 | Time.local(2012,04,30) |
19
+ | 01052012 | Time.local(2012,05,01) |
20
+ | 20120501 | Time.local(2012,05,01) |
21
+ | 24-12-2011 22:10:54 | Time.local(2011,12,24,22,10,54) |
22
+ | 2011-12-24_12:10:54 | Time.local(2011,12,24,12,10,54) |
23
+ | 24/12/2011-12:20:31 | Time.local(2011,12,24,12,20,31) |
24
+ | 01052012122031 | Time.local(2012,05,01,12,20,31) |
25
+ | 20120501122031 | Time.local(2012,05,01,12,20,31) |
26
+
27
+
28
+ using .add or .substract
29
+
30
+ |starting object | method | arguments | resulting object |
31
+ | Time.local(2011,12,24,22,10,54) | add | {:year => 2, :month => 1 } | Time.local(2011,12,24,22,10,54) + (2*60*60*24*365 + 60*60*24*30) |
32
+ | Time.local(2012,05,01,12,20,31) | substract | {:month => 2, :day => 3} | Time.local(2012,05,01,12,20,31) - (60*60*24*30*2 + 60*60*24*3)|
33
+ | Time.local(2011,12,24,22,10,54) | add | {:day => 1, :hour => 3} |Time.local(2011,12,24,22,10,54) + (60*60*24 + 60*60*3) |
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time-helper
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.0"
4
+ version: 1.0.01
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Silva
@@ -28,6 +28,7 @@ extra_rdoc_files: []
28
28
 
29
29
  files:
30
30
  - lib/time-helper.rb
31
+ - README
31
32
  has_rdoc: true
32
33
  homepage: https://github.com/awls99/time-helper
33
34
  licenses: []