week_calc 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/week_calc.rb +24 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 094cf09299c48b55411574da96001af0bc80eb11
|
4
|
+
data.tar.gz: 9b9a7d7b013e3fb16f789544ed7c13d1db9e5fa6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8f819a13dbe196092ed0d650dc9c32312a5325d05e04f6cfbc0ab7b2cd1fafabf8a2407f36bb3d76204e34eb1c7011fbf5493a993b2ab4ac8d31673e63f1f9e2
|
7
|
+
data.tar.gz: aaa1f1a917f497c559b224b27e05ca186f80d2bd305e92fcbd3e1ddf43d7757346a74f7cffbfad014ff3a8c1b2f605d0ea932dce6d5ad018cf25658e18ea191c
|
data/lib/week_calc.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'date'
|
2
|
+
Date.class_eval do
|
3
|
+
def self.get_weeks(start_date, end_date)
|
4
|
+
#Calculations will return a date object
|
5
|
+
start_date_parsed = Date.parse(start_date) rescue nil
|
6
|
+
end_date_parsed = Date.parse(end_date) rescue nil
|
7
|
+
if start_date_parsed.nil? && end_date_parsed.nil?
|
8
|
+
nil
|
9
|
+
else
|
10
|
+
days_gap = end_date_parsed.mjd - start_date_parsed.mjd
|
11
|
+
weeks = (days_gap/7).abs
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.week_from_now(date)
|
16
|
+
date_parsed = Date.parse(date) rescue nil
|
17
|
+
if date_parsed.nil?
|
18
|
+
nil
|
19
|
+
else
|
20
|
+
days_gap = Date.today.mjd - date_parsed.mjd
|
21
|
+
weeks = (days_gap/7).abs
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: week_calc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Souranil Sen, Amit Suryavanshi, Yashasree Barve, Twinkal Savani, Priya Joshi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A week calculator gem
|
14
|
+
email: 'souranil@gmail.com, amitbsuryavanshi@gmail.com, yashasree.barve@gmail.com,
|
15
|
+
twinkal.savani@gmail.com, priya.joshi@gmail.com '
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/week_calc.rb
|
21
|
+
homepage: http://rubygems.org/gems/week_calc
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.0.3
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: A week calculator gem
|
45
|
+
test_files: []
|