darian 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.rspec +1 -0
- data/.travis.yml +6 -0
- data/.yardopts +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +24 -0
- data/LICENSE +165 -0
- data/README.md +41 -0
- data/Rakefile +34 -0
- data/darian.gemspec +27 -0
- data/lib/darian.rb +23 -0
- data/lib/darian/time.rb +173 -0
- data/lib/darian/version.rb +4 -0
- data/spec/darian_spec.rb +48 -0
- data/spec/spec_helper.rb +7 -0
- metadata +125 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format documentation --colour
|
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
rake (0.9.2.2)
|
6
|
+
redcarpet (2.1.1)
|
7
|
+
rspec (2.10.0)
|
8
|
+
rspec-core (~> 2.10.0)
|
9
|
+
rspec-expectations (~> 2.10.0)
|
10
|
+
rspec-mocks (~> 2.10.0)
|
11
|
+
rspec-core (2.10.0)
|
12
|
+
rspec-expectations (2.10.0)
|
13
|
+
diff-lcs (~> 1.1.3)
|
14
|
+
rspec-mocks (2.10.1)
|
15
|
+
yard (0.8.1)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
rake
|
22
|
+
redcarpet
|
23
|
+
rspec
|
24
|
+
yard
|
data/LICENSE
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Darian Mars Calendar Converter
|
2
|
+
|
3
|
+
The [Darian calendar] is a proposed system of time-keeping on the planet Mars.
|
4
|
+
It was created by aerospace engineer and political scientist Thomas Gangale
|
5
|
+
in 1985. This library use version 2002 year of calendar with Telescopic Epoch
|
6
|
+
(1609 instead of 1975 year in original calendar propose).
|
7
|
+
|
8
|
+
This Ruby library convert Earth time to Mars time in Darian calendar.
|
9
|
+
|
10
|
+
Based on [JS converter] by Thomas Gangale.
|
11
|
+
|
12
|
+
[Darian calendar]: http://en.wikipedia.org/wiki/Darian_calendar
|
13
|
+
[JS converter]: http://pweb.jps.net/~tgangale/mars/converter/calendar_clock.htm
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'darian'
|
19
|
+
|
20
|
+
earth_time = Time.now
|
21
|
+
mars_time = Darian::Time.from_earth(earth_time)
|
22
|
+
|
23
|
+
mars_time.to_s #=> "214-09-17 15:07:17"
|
24
|
+
|
25
|
+
mars_time.year #=> 214
|
26
|
+
mars_time.month #=> 9
|
27
|
+
mars_time.sol #=> 17
|
28
|
+
mars_time.day #=> 17
|
29
|
+
|
30
|
+
mars_time.month_name #=> "Aries"
|
31
|
+
mars_time.week_sol_name #=> "Sol Martis"
|
32
|
+
```
|
33
|
+
|
34
|
+
## License
|
35
|
+
|
36
|
+
R18n is licensed under the GNU Lesser General Public License version 3.
|
37
|
+
See the LICENSE file or http://www.gnu.org/licenses/lgpl.html.
|
38
|
+
|
39
|
+
## Author
|
40
|
+
|
41
|
+
Andrey “A.I.” Sitnik <andrey@sitnik.ru>
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bundler/setup'
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
rescue LoadError
|
9
|
+
puts "Bundler not available. Install it with: gem install bundler"
|
10
|
+
end
|
11
|
+
|
12
|
+
require File.join(File.dirname(__FILE__), 'lib/darian/version')
|
13
|
+
|
14
|
+
require 'rspec/core/rake_task'
|
15
|
+
|
16
|
+
RSpec::Core::RakeTask.new
|
17
|
+
|
18
|
+
require 'yard'
|
19
|
+
YARD::Rake::YardocTask.new do |yard|
|
20
|
+
yard.options << "--title='Darian Mars Calendar Converter #{Darian::VERSION}'"
|
21
|
+
end
|
22
|
+
|
23
|
+
task :clobber_doc do
|
24
|
+
rm_r 'doc' rescue nil
|
25
|
+
rm_r '.yardoc' rescue nil
|
26
|
+
end
|
27
|
+
task :clobber_package do
|
28
|
+
rm_r 'pkg' rescue nil
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Delete all generated files'
|
32
|
+
task :clobber => [:clobber_package, :clobber_doc]
|
33
|
+
|
34
|
+
task :default => :spec
|
data/darian.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require './lib/darian/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.platform = Gem::Platform::RUBY
|
5
|
+
s.name = 'darian'
|
6
|
+
s.version = Darian::VERSION.dup
|
7
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
8
|
+
s.summary = 'Darian Mars Calendar Converter.'
|
9
|
+
s.description = <<-EOF
|
10
|
+
Converter from Earth dates to mars dates by Darian calendar.
|
11
|
+
EOF
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
15
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
16
|
+
s.require_path = 'lib'
|
17
|
+
|
18
|
+
s.author = 'Andrey "A.I." Sitnik'
|
19
|
+
s.email = 'andrey@sitnik.ru'
|
20
|
+
s.homepage = 'https://github.com/ai/darian'
|
21
|
+
|
22
|
+
s.add_development_dependency "bundler", [">= 1.0.10"]
|
23
|
+
s.add_development_dependency "yard", [">= 0"]
|
24
|
+
s.add_development_dependency "rake", [">= 0"]
|
25
|
+
s.add_development_dependency "rspec", [">= 0"]
|
26
|
+
s.add_development_dependency "redcarpet", [">= 0"]
|
27
|
+
end
|
data/lib/darian.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
=begin
|
3
|
+
Main file to load all neccessary classes for Darian Mars calendar.
|
4
|
+
|
5
|
+
Copyright (C) 2012 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
|
6
|
+
|
7
|
+
This program is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU Lesser General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
This program is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
GNU Lesser General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU Lesser General Public License
|
18
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
=end
|
20
|
+
|
21
|
+
dir = File.join(File.dirname(__FILE__), 'darian')
|
22
|
+
require File.join(dir, 'version')
|
23
|
+
require File.join(dir, 'time')
|
data/lib/darian/time.rb
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
=begin
|
3
|
+
Darian Mars calendar time converter.
|
4
|
+
|
5
|
+
Copyright (C) 2012 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
|
6
|
+
|
7
|
+
This program is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU Lesser General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
This program is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
GNU Lesser General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU Lesser General Public License
|
18
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
=end
|
20
|
+
|
21
|
+
module Darian
|
22
|
+
# Darian Mars calendar time converter.
|
23
|
+
#
|
24
|
+
# mars = Darian::Time.from_earth(Time.now)
|
25
|
+
# puts mars
|
26
|
+
# puts mars.sol_name
|
27
|
+
class Time
|
28
|
+
MARS_TO_EARTH_DAYS = 1.027491251
|
29
|
+
EPOCH_OFFSET = 587744.77817
|
30
|
+
ROUND_UP_SECOND = 1/86400
|
31
|
+
|
32
|
+
attr_reader :year
|
33
|
+
attr_reader :season
|
34
|
+
attr_reader :month
|
35
|
+
attr_reader :month_name
|
36
|
+
attr_reader :sol
|
37
|
+
attr_reader :week_sol
|
38
|
+
attr_reader :hour
|
39
|
+
attr_reader :min
|
40
|
+
attr_reader :sec
|
41
|
+
|
42
|
+
alias :day :sol
|
43
|
+
alias :week_day :week_sol
|
44
|
+
|
45
|
+
attr_reader :sol_of_season
|
46
|
+
attr_reader :month_of_season
|
47
|
+
|
48
|
+
# Return Mars time converted from Earth time.
|
49
|
+
#
|
50
|
+
# Darian.from_earth(Time.now)
|
51
|
+
def self.from_earth(time)
|
52
|
+
# 719527 is days until 0 year for Unix Epoch
|
53
|
+
days = (time.to_i / 86400.0) + 719527
|
54
|
+
sols = (days - EPOCH_OFFSET) / MARS_TO_EARTH_DAYS
|
55
|
+
self.new(sols)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Create Mars time by sols since 0 year.
|
59
|
+
#
|
60
|
+
# It is internal contructor. Use `Darian.from_earth`.
|
61
|
+
def initialize(sols)
|
62
|
+
sD = (sols / 334296).floor
|
63
|
+
doD = (sols - (sD * 334296)).floor
|
64
|
+
|
65
|
+
sC = 0
|
66
|
+
doC = doD
|
67
|
+
sC = ((doD - 1) / 66859).floor if doD != 0
|
68
|
+
doC -= (sC * 66859) + 1 if sC != 0
|
69
|
+
|
70
|
+
sX = 0
|
71
|
+
doX = doC
|
72
|
+
if sC != 0 # century that does not begin with leap day
|
73
|
+
sX = ((doC + 1) / 6686).floor
|
74
|
+
doX -= sX * 6686 - 1 if sX != 0
|
75
|
+
else
|
76
|
+
sX = (doC / 6686).floor
|
77
|
+
doX -= sX * 6686 if sX != 0
|
78
|
+
end
|
79
|
+
|
80
|
+
sII = 0
|
81
|
+
doII = doX
|
82
|
+
if sC != 0 and sX == 0 # decade that does not begin with leap day
|
83
|
+
sII = (doX / 1337).floor
|
84
|
+
doII -= sII * 1337 if sII != 0
|
85
|
+
else # 1338, 1337, 1337, 1337 …
|
86
|
+
sII = ((doX - 1) / 1337).floor if doX != 0
|
87
|
+
doII -= (sII * 1337 + 1) if sII != 0
|
88
|
+
end
|
89
|
+
|
90
|
+
sI = 0
|
91
|
+
doI = doII
|
92
|
+
if sII == 0 and (sX != 0 or (sX == 0 and sC == 0))
|
93
|
+
sI = (doII / 669).floor
|
94
|
+
doI -= 669 if sI != 0
|
95
|
+
else # 668, 669
|
96
|
+
sI = ((doII + 1) / 669).floor
|
97
|
+
doI -= 668 if sI != 0
|
98
|
+
end
|
99
|
+
|
100
|
+
@year = 500 * sD + 100 * sC + 10 * sX + 2 * sII + sI
|
101
|
+
@season = if doI < 167
|
102
|
+
0
|
103
|
+
elsif doI < 334
|
104
|
+
1
|
105
|
+
elsif doI < 501
|
106
|
+
2
|
107
|
+
else
|
108
|
+
3
|
109
|
+
end
|
110
|
+
@sol_of_season = doI - 167 * @season
|
111
|
+
@month_of_season = (@sol_of_season / 28).floor
|
112
|
+
|
113
|
+
@month = @month_of_season + 6 * @season + 1
|
114
|
+
|
115
|
+
@sol = doI - ((@month - 1) * 28 - @season) + 1
|
116
|
+
@week_sol = (@sol - 1) % 7 + 1
|
117
|
+
|
118
|
+
hour = (sols - sols.floor) * 24
|
119
|
+
min = (hour - hour.floor) * 60
|
120
|
+
|
121
|
+
@hour = hour.floor
|
122
|
+
@min = min.floor
|
123
|
+
@sec = ((min - min.floor) * 60).floor
|
124
|
+
end
|
125
|
+
|
126
|
+
def month_name
|
127
|
+
case @month
|
128
|
+
when 1 then 'Sagittarius'
|
129
|
+
when 2 then 'Dhanus'
|
130
|
+
when 3 then 'Capricornus'
|
131
|
+
when 4 then 'Makara'
|
132
|
+
when 5 then 'Aquarius'
|
133
|
+
when 6 then 'Kumbha'
|
134
|
+
when 7 then 'Pisces'
|
135
|
+
when 8 then 'Mina'
|
136
|
+
when 9 then 'Aries'
|
137
|
+
when 10 then 'Mesha'
|
138
|
+
when 11 then 'Taurus'
|
139
|
+
when 12 then 'Rishabha'
|
140
|
+
when 13 then 'Gemini'
|
141
|
+
when 14 then 'Mithuna'
|
142
|
+
when 15 then 'Cancer'
|
143
|
+
when 16 then 'Karka'
|
144
|
+
when 17 then 'Leo'
|
145
|
+
when 18 then 'Simha'
|
146
|
+
when 19 then 'Virgo'
|
147
|
+
when 20 then 'Kanya'
|
148
|
+
when 21 then 'Libra'
|
149
|
+
when 22 then 'Tula'
|
150
|
+
when 23 then 'Scorpius'
|
151
|
+
when 24 then 'Vrishika'
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def week_sol_name
|
156
|
+
case @week_sol
|
157
|
+
when 1 then 'Sol Solis'
|
158
|
+
when 2 then 'Sol Lunae'
|
159
|
+
when 3 then 'Sol Martis'
|
160
|
+
when 4 then 'Sol Mercurii'
|
161
|
+
when 5 then 'Sol Jovis'
|
162
|
+
when 6 then 'Sol Veneris'
|
163
|
+
when 7 then 'Sol Saturni'
|
164
|
+
end
|
165
|
+
end
|
166
|
+
alias :week_day_name :week_sol_name
|
167
|
+
|
168
|
+
def to_s
|
169
|
+
sprintf '%d-%02d-%02d %02d:%02d:%02d',
|
170
|
+
@year, @month, @sol, @hour, @min, @sec
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
data/spec/darian_spec.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path('../spec_helper', __FILE__)
|
3
|
+
|
4
|
+
describe Darian do
|
5
|
+
|
6
|
+
it "should return own version" do
|
7
|
+
Darian::VERSION.should be_a(String)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Darian::Time do
|
11
|
+
before do
|
12
|
+
earth = Time.parse('2012-05-16 10:00:00 UTC')
|
13
|
+
@mars = Darian::Time.from_earth(earth)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should convert Earch time to Mars" do
|
17
|
+
@mars.year.should == 214
|
18
|
+
@mars.month.should == 9
|
19
|
+
@mars.sol.should == 17
|
20
|
+
@mars.hour.should == 15
|
21
|
+
@mars.min.should == 7
|
22
|
+
@mars.sec.should == 17
|
23
|
+
|
24
|
+
@mars.week_sol.should == 3
|
25
|
+
|
26
|
+
@mars.season.should == 1
|
27
|
+
@mars.month_of_season.should == 2
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should set month name" do
|
31
|
+
@mars.month_name.should == 'Aries'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should set week sol name" do
|
35
|
+
@mars.week_sol_name.should == 'Sol Martis'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should alias day to sol" do
|
39
|
+
@mars.day.should == @mars.sol
|
40
|
+
@mars.week_day.should == @mars.week_sol
|
41
|
+
@mars.week_day_name.should == @mars.week_sol_name
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should print mars time" do
|
45
|
+
@mars.to_s.should == '214-09-17 15:07:17'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: darian
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrey "A.I." Sitnik
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: &13725480 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.10
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *13725480
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: yard
|
27
|
+
requirement: &13724980 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *13724980
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &13724500 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *13724500
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &13723960 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *13723960
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: redcarpet
|
60
|
+
requirement: &13723480 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *13723480
|
69
|
+
description: ! ' Converter from Earth dates to mars dates by Darian calendar.
|
70
|
+
|
71
|
+
'
|
72
|
+
email: andrey@sitnik.ru
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files:
|
76
|
+
- README.md
|
77
|
+
- LICENSE
|
78
|
+
files:
|
79
|
+
- .gitignore
|
80
|
+
- .rspec
|
81
|
+
- .travis.yml
|
82
|
+
- .yardopts
|
83
|
+
- Gemfile
|
84
|
+
- Gemfile.lock
|
85
|
+
- LICENSE
|
86
|
+
- README.md
|
87
|
+
- Rakefile
|
88
|
+
- darian.gemspec
|
89
|
+
- lib/darian.rb
|
90
|
+
- lib/darian/time.rb
|
91
|
+
- lib/darian/version.rb
|
92
|
+
- spec/darian_spec.rb
|
93
|
+
- spec/spec_helper.rb
|
94
|
+
homepage: https://github.com/ai/darian
|
95
|
+
licenses: []
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
hash: -4170314655358135603
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
segments:
|
116
|
+
- 0
|
117
|
+
hash: -4170314655358135603
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 1.8.11
|
121
|
+
signing_key:
|
122
|
+
specification_version: 3
|
123
|
+
summary: Darian Mars Calendar Converter.
|
124
|
+
test_files: []
|
125
|
+
has_rdoc:
|