english_nepali_date_converter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/english_nepali_date_converter.gemspec +24 -0
- data/lib/english_nepali_date_converter.rb +4 -0
- data/lib/english_nepali_date_converter/bs_date.rb +95 -0
- data/lib/english_nepali_date_converter/date_conversion.rb +150 -0
- data/lib/english_nepali_date_converter/version.rb +3 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6c1b6e1517a27ca7832c04fd19c2d392b95092cc
|
4
|
+
data.tar.gz: 03dae0683c74ac7626b3b5c3bb5610cf0518312b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cc16224f4372faab604f5cad8dc73ad1dcf6eb668344dde5acd522cf27aefeba4bc2111e105c237a515a1feea8b0a0e1da510fc365aea372c42c949f88a3d678
|
7
|
+
data.tar.gz: 6497c7a024e3c7f20fb9d563b4f5471f9d74adf2d1f8388937d8f0a01783362c4eda9c43b6496622ecabf33a21398c14ffa2bbf62cb21ddd0b6f795c3dd0256b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 dlamichhane
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# EnglishNepaliDateConverter
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'english_nepali_date_converter'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install english_nepali_date_converter
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
call = EnglishNepaliDateConverter::DateConversion.new
|
24
|
+
p call.eng_to_nep(16,01,2014)
|
25
|
+
p call.nep_to_eng(03,10,2070)
|
26
|
+
```
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'english_nepali_date_converter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "english_nepali_date_converter"
|
8
|
+
spec.version = EnglishNepaliDateConverter::VERSION
|
9
|
+
spec.date = %{2014-01-16}
|
10
|
+
spec.authors = ["dlamichhane"]
|
11
|
+
spec.email = ["dlamichhane@hotmail.com"]
|
12
|
+
spec.description = %q{"Conversion of Gregorian calendar to Nepali Calendar"}
|
13
|
+
spec.summary = %q{Converts the English calendar date to Nepali calendar date}
|
14
|
+
spec.homepage = %q{https://github.com/dlamichhane/english_nepali_date_converter}
|
15
|
+
spec.licenses = ['MIT']
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module BsDate
|
2
|
+
BS_DATES = {
|
3
|
+
0 => [2000, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
4
|
+
1 => [2001, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
5
|
+
2 => [2002, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
6
|
+
3 => [2003, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
7
|
+
4 => [2004, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
8
|
+
5 => [2005, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
9
|
+
6 => [2006, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
10
|
+
7 => [2007, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
11
|
+
8 => [2008, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
|
12
|
+
9 => [2009, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
13
|
+
10 => [2010, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
14
|
+
11 => [2011, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
15
|
+
12 => [2012, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
16
|
+
13 => [2013, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
17
|
+
14 => [2014, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
18
|
+
15 => [2015, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
19
|
+
16 => [2016, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
20
|
+
17 => [2017, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
21
|
+
18 => [2018, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
22
|
+
19 => [2019, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
23
|
+
20 => [2020, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
24
|
+
21 => [2021, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
25
|
+
22 => [2022, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
26
|
+
23 => [2023, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
27
|
+
24 => [2024, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
28
|
+
25 => [2025, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
29
|
+
26 => [2026, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
30
|
+
27 => [2027, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
31
|
+
28 => [2028, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
32
|
+
29 => [2029, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
|
33
|
+
30 => [2030, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
34
|
+
31 => [2031, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
35
|
+
32 => [2032, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
36
|
+
33 => [2033, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
37
|
+
34 => [2034, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
38
|
+
35 => [2035, 30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
|
39
|
+
36 => [2036, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
40
|
+
37 => [2037, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
41
|
+
38 => [2038, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
42
|
+
39 => [2039, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
43
|
+
40 => [2040, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
44
|
+
41 => [2041, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
45
|
+
42 => [2042, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
46
|
+
43 => [2043, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
47
|
+
44 => [2044, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
48
|
+
45 => [2045, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
49
|
+
46 => [2046, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
50
|
+
47 => [2047, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
51
|
+
48 => [2048, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
52
|
+
49 => [2049, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
53
|
+
50 => [2050, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
54
|
+
51 => [2051, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
55
|
+
52 => [2052, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
56
|
+
53 => [2053, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
57
|
+
54 => [2054, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
58
|
+
55 => [2055, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
59
|
+
56 => [2056, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
|
60
|
+
57 => [2057, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
61
|
+
58 => [2058, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
62
|
+
59 => [2059, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
63
|
+
60 => [2060, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
64
|
+
61 => [2061, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
65
|
+
62 => [2062, 30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31],
|
66
|
+
63 => [2063, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
67
|
+
64 => [2064, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
68
|
+
65 => [2065, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
69
|
+
66 => [2066, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
|
70
|
+
67 => [2067, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
71
|
+
68 => [2068, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
72
|
+
69 => [2069, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
73
|
+
70 => [2070, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
74
|
+
71 => [2071, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
75
|
+
72 => [2072, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
76
|
+
73 => [2073, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
77
|
+
74 => [2074, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
78
|
+
75 => [2075, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
79
|
+
76 => [2076, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
80
|
+
77 => [2077, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
81
|
+
78 => [2078, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
82
|
+
79 => [2079, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
83
|
+
80 => [2080, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
84
|
+
81 => [2081, 31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
85
|
+
82 => [2082, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
86
|
+
83 => [2083, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
|
87
|
+
84 => [2084, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
|
88
|
+
85 => [2085, 31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30],
|
89
|
+
86 => [2086, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
90
|
+
87 => [2087, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
|
91
|
+
88 => [2088, 30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30],
|
92
|
+
89 => [2089, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
93
|
+
90 => [2090, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30]
|
94
|
+
}
|
95
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
module EnglishNepaliDateConverter
|
2
|
+
|
3
|
+
class DateConversion
|
4
|
+
attr_accessor :year, :month, :day_in_month, :day_of_week, :week_day, :month_number
|
5
|
+
|
6
|
+
EN_DAY = { 1 => "Sunday", 2 => "Monday", 3 => "Tuesday", 4 => "Wednesday", 5 => "Thursday", 6 => "Friday", 7 => "Saturday" }
|
7
|
+
NP_DAY = { 1 => "Aaitabar", 2 => "Sombar", 3 => "Mangalbar", 4 => "Budhabar", 5 => "Bihibar", 6 => "Sukrabar", 7 => "Sanibar" }
|
8
|
+
|
9
|
+
NP_MONTH = { 1 => "Baisakh", 2 => "Jestha", 3 => "Asar", 4 => "Shrawan", 5 => "Bhadra", 6 => "Ashoj",
|
10
|
+
7 => "Kartik", 8 => "Mangsir", 9 => "Poush", 10 => "Magh", 11 => "Falgun", 12 => "Chaitra" }
|
11
|
+
|
12
|
+
EN_MONTH = { 1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June",
|
13
|
+
7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December" }
|
14
|
+
|
15
|
+
def eng_to_nep(*args)
|
16
|
+
|
17
|
+
# Normal days in month except leap year
|
18
|
+
enDaysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31]
|
19
|
+
return "Enter appropriate month" unless (1..12).include?(args[1])
|
20
|
+
|
21
|
+
if Date.leap?(args[2].to_i)
|
22
|
+
return "Enter appropriate day of the month" unless (1.. + enDaysInMonth[args[1].to_i - 1] + 1).include?(args[0])
|
23
|
+
else
|
24
|
+
return "Enter appropriate day of the month" unless (1.. + enDaysInMonth[args[1].to_i - 1]).include?(args[0])
|
25
|
+
end
|
26
|
+
|
27
|
+
formated_date = args[0].to_s + "-" + args[1].to_s + "-" + args[2].to_s
|
28
|
+
starting_date = DateTime.parse("01-01-1944").mjd.to_i
|
29
|
+
ending_date = DateTime.parse("31-12-2033").mjd
|
30
|
+
date_to_convert = DateTime.parse(formated_date).mjd
|
31
|
+
return "Enter a valid date from 01-01-1944 to 31-12-2033" unless (starting_date..ending_date).include?(date_to_convert)
|
32
|
+
|
33
|
+
enTotalDays = date_to_convert - starting_date
|
34
|
+
|
35
|
+
# Conversion of 01-01-1944 AD will be 17.01.2000 BS. Take this BS as a base date
|
36
|
+
@year = npStartYear = 2000
|
37
|
+
@month_number = npStartMth = 9
|
38
|
+
@day_in_month = npStartDay = 17
|
39
|
+
|
40
|
+
startingIndexOfBSDate = 0
|
41
|
+
@day_of_week = 7 # Saturday as Day 7 and Sunday as Day 1 of the week
|
42
|
+
|
43
|
+
while enTotalDays !=0
|
44
|
+
@day_in_month += 1
|
45
|
+
@day_of_week += 1
|
46
|
+
|
47
|
+
if @day_in_month > BsDate::BS_DATES[startingIndexOfBSDate][npStartMth]
|
48
|
+
@month_number += 1
|
49
|
+
@day_in_month = 1
|
50
|
+
npStartMth += 1
|
51
|
+
end
|
52
|
+
|
53
|
+
@day_of_week = 1 if @day_of_week > 7
|
54
|
+
|
55
|
+
if @month_number > 12
|
56
|
+
@year += 1
|
57
|
+
@month_number = 1
|
58
|
+
end
|
59
|
+
|
60
|
+
if npStartMth > 12
|
61
|
+
npStartMth = 1
|
62
|
+
startingIndexOfBSDate += 1
|
63
|
+
end
|
64
|
+
|
65
|
+
enTotalDays -= 1
|
66
|
+
end
|
67
|
+
|
68
|
+
@week_day = self.class.get_day_of_week(@day_of_week, 'np')
|
69
|
+
@month = self.class.get_month_name(@month_number, 'np')
|
70
|
+
return self
|
71
|
+
end
|
72
|
+
|
73
|
+
def nep_to_eng(*args)
|
74
|
+
|
75
|
+
return "Enter appropriate month" unless (1..12).include?(args[1])
|
76
|
+
|
77
|
+
check_year = []
|
78
|
+
for i in 0..90
|
79
|
+
check_year << BsDate::BS_DATES[i][0]
|
80
|
+
end
|
81
|
+
|
82
|
+
return "Enter appropriate year" unless check_year.index(args[2])
|
83
|
+
|
84
|
+
return "Enter appropriate day of the month" if BsDate::BS_DATES[check_year.index(args[2])][args[1]] < args[0]
|
85
|
+
|
86
|
+
enStartYear = 1943; enStartMonth = 4; enStartDay = 14 - 1
|
87
|
+
|
88
|
+
npStartYear = 2000; npStartMth = 1; npStartDay = 1
|
89
|
+
|
90
|
+
@day_of_week = 4 - 1
|
91
|
+
# (2000..2089).include?(args[2]) && (01..12).include?(args[1]) && (01..32).include?(args[0])
|
92
|
+
# 2000-01-01 to 2089-12-32
|
93
|
+
enDaysInMonth = [0,31,28,31,30,31,30,31,31,30,31,30,31]
|
94
|
+
leapEnDaysInMonth = [0,31,29,31,30,31,30,31,31,30,31,30,31]
|
95
|
+
|
96
|
+
npYearDiff = args[2] - npStartYear - 1
|
97
|
+
npTotalDays = 0
|
98
|
+
|
99
|
+
for i in 0.. + npYearDiff
|
100
|
+
BsDate::BS_DATES[i].shift
|
101
|
+
npTotalDays += BsDate::BS_DATES[i].inject(:+)
|
102
|
+
end
|
103
|
+
|
104
|
+
npMonthDiff = args[1] -1
|
105
|
+
|
106
|
+
for i in 1.. + npMonthDiff
|
107
|
+
npTotalDays += BsDate::BS_DATES[args[2] - npStartYear][i]
|
108
|
+
end
|
109
|
+
|
110
|
+
npTotalDays += args[0]
|
111
|
+
|
112
|
+
@day_in_month = enStartDay
|
113
|
+
@month_number = enStartMonth;
|
114
|
+
@year = enStartYear;
|
115
|
+
|
116
|
+
while npTotalDays != 0
|
117
|
+
|
118
|
+
total_month_days = Date.leap?(year) ? leapEnDaysInMonth[@month_number] : enDaysInMonth[@month_number]
|
119
|
+
|
120
|
+
@day_in_month += 1
|
121
|
+
@day_of_week += 1
|
122
|
+
|
123
|
+
if @day_in_month > total_month_days
|
124
|
+
@month_number += 1
|
125
|
+
@day_in_month = 1
|
126
|
+
|
127
|
+
if @month_number > 12
|
128
|
+
@year += 1
|
129
|
+
@month_number = 1
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
@day_of_week = 1 if @day_of_week > 7
|
134
|
+
npTotalDays -= 1
|
135
|
+
end
|
136
|
+
@week_day = self.class.get_day_of_week(@day_of_week, 'en')
|
137
|
+
@month = self.class.get_month_name(@month_number, 'en')
|
138
|
+
return self
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.get_day_of_week(day, type)
|
142
|
+
type == "en" ? self::EN_DAY[day] : self::NP_DAY[day]
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.get_month_name(month, type)
|
146
|
+
type == "en" ? self::EN_MONTH[month] : self::NP_MONTH[month]
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: english_nepali_date_converter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dlamichhane
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: '"Conversion of Gregorian calendar to Nepali Calendar"'
|
42
|
+
email:
|
43
|
+
- dlamichhane@hotmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- english_nepali_date_converter.gemspec
|
54
|
+
- lib/english_nepali_date_converter.rb
|
55
|
+
- lib/english_nepali_date_converter/bs_date.rb
|
56
|
+
- lib/english_nepali_date_converter/date_conversion.rb
|
57
|
+
- lib/english_nepali_date_converter/version.rb
|
58
|
+
homepage: https://github.com/dlamichhane/english_nepali_date_converter
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.1.11
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Converts the English calendar date to Nepali calendar date
|
82
|
+
test_files: []
|