chronology 0.0.2 → 0.0.3

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/lib/chronology.rb +28 -0
  2. metadata +2 -2
@@ -1,9 +1,37 @@
1
+ require 'date'
2
+
1
3
  class Chronology
2
4
  def self.days_since(date)
3
5
  DateTime.now.mjd - date.mjd
4
6
  end
5
7
 
8
+ def self.weeks_since(date)
9
+ self.days_since(date) / 7
10
+ end
11
+
12
+ def self.months_since(date)
13
+ now = DateTime.now
14
+ (now.month - date.month) + 12 * (now.year - date.year)
15
+ end
16
+
6
17
  def self.years_since(date)
7
18
  (self.days_since(date) / 365.25).round(2)
8
19
  end
20
+
21
+ def self.days_until(date)
22
+ date.mjd - DateTime.now.mjd
23
+ end
24
+
25
+ def self.weeks_until(date)
26
+ self.days_until(date) / 7
27
+ end
28
+
29
+ def self.months_until(date)
30
+ now = DateTime.now
31
+ (date.month - now.month) + 12 * (date.year - now.year)
32
+ end
33
+
34
+ def self.years_until(date)
35
+ (self.days_until(date) / 365.25).round(2)
36
+ end
9
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chronology
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-25 00:00:00.000000000 Z
12
+ date: 2013-02-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A Ruby gem for interacting with chronological information.
15
15
  email: pso@pso.io