months_caluculator 0.0.1

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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+ gem 'rails', '3.0.7'
3
+ # Specify your gem's dependencies in months_caluculator.gemspec
4
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,28 @@
1
+ require "months_caluculator/version"
2
+
3
+ module MonthsCaluculator
4
+ # Your code goes here...
5
+ def self.description
6
+ p "To Caluculate Exact Number of Months We Will Use this gem"
7
+ end
8
+
9
+ def self.get_exact_number_of_months(from_date, to_date)
10
+ number_of_months = 0
11
+ if from_date.blank? && to_date.blank?
12
+ raise "Please Enter From and To Dates"
13
+ elsif from_date.blank?
14
+ raise "Please Enter From Date"
15
+ elsif to_date.blank?
16
+ raise "Please Enter To Date"
17
+ elsif from_date.present? && to_date.present?
18
+ from_date = from_date.to_date
19
+ to_date = to_date.to_date
20
+ number_of_months = (to_date.year*12+to_date.month) - (from_date.year*12+from_date.month)
21
+ end_date = from_date.to_date + number_of_months.months
22
+ number_of_days = to_date.day-end_date.day
23
+ # If the number of days in month is more than 15 then we will assume it as one month and we add it below.
24
+ number_of_months = number_of_months + 1 if number_of_days >=15
25
+ end
26
+ number_of_months
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module MonthsCaluculator
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "months_caluculator/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "months_caluculator"
7
+ s.version = MonthsCaluculator::VERSION
8
+ s.authors = ["Sateesh Kambhampati"]
9
+ s.email = ["sateesh.k09@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = "Purpose is to caluculate exact number of months between two dates"
12
+ s.description = "A simple gem to caluculate exact number of months"
13
+
14
+ s.rubyforge_project = "months_caluculator"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: months_caluculator
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Sateesh Kambhampati
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-07-07 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: A simple gem to caluculate exact number of months
22
+ email:
23
+ - sateesh.k09@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - Rakefile
34
+ - lib/months_caluculator.rb
35
+ - lib/months_caluculator/version.rb
36
+ - months_caluculator.gemspec
37
+ homepage: ""
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options: []
42
+
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ hash: 3
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project: months_caluculator
66
+ rubygems_version: 1.8.24
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Purpose is to caluculate exact number of months between two dates
70
+ test_files: []
71
+