new_time 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 +22 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +24 -0
- data/Rakefile +2 -0
- data/bin/new_time +9 -0
- data/lib/new_time/version.rb +3 -0
- data/lib/new_time.rb +55 -0
- data/new_time.gemspec +25 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a86c25b0008c1dadb0688466d715a0b87859fed0
|
4
|
+
data.tar.gz: ace76a625c8af3981a8d2f14e9fc76ba3647a80e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5925b6b0073a9ad1ea3d113844b38899dbe1e9dfbe52441cb66929f7aa1ebdf3ac7353d74e985938b1e8ebc9e1d6deb7e60f7971570fb3d8f3db0c02bcfb587d
|
7
|
+
data.tar.gz: 2424df0db905db66038ddc3779a3c6f4f6e56a85aae957ab301e0149c1d77177a465d1059df76643b236d6247b81338af0cebe445127f1d2a16a6afb1d18ae47
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p353
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Matthew Landauer
|
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,24 @@
|
|
1
|
+
# An amusing experiment to try on myself
|
2
|
+
|
3
|
+
This is a new kind of time. One that is different on every point on earth and different on every day.
|
4
|
+
|
5
|
+
The idea is simple.
|
6
|
+
|
7
|
+
The sun rises at 6 AM and sets at 6 PM. It does this every day wherever you are.
|
8
|
+
|
9
|
+
Time runs at a constant speed during daylight hours. It does this at night as well but those speeds are usually not going to be the same.
|
10
|
+
|
11
|
+
During summer, time is going to go slower during the day and faster at night.
|
12
|
+
During winter, time is going to move quickly during the day and slowly at night.
|
13
|
+
|
14
|
+
One other nitfy artifact is that midday (12 PM) will be the time when the sun is at its highest.
|
15
|
+
|
16
|
+
This is really an experiment to see what a different sense of time means. A second can be shorter or longer depending on the season but you are inextricably linked to the world via the sunrise and sunset.
|
17
|
+
|
18
|
+
So right now all this little bit of code does is give me the new time.
|
19
|
+
|
20
|
+
But for the time being it only works in Katoomba, Australia.
|
21
|
+
|
22
|
+
## License
|
23
|
+
|
24
|
+
MIT License. Copyright 2015 Matthew Landauer
|
data/Rakefile
ADDED
data/bin/new_time
ADDED
data/lib/new_time.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'solareventcalculator'
|
2
|
+
|
3
|
+
class NewTime
|
4
|
+
attr_accessor :hours, :minutes, :seconds, :fractional
|
5
|
+
|
6
|
+
def initialize(hours, minutes, seconds, fractional)
|
7
|
+
@hours, @minutes, @seconds, @fractional = hours, minutes, seconds, fractional
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.current_time(latitude, longitude, tz)
|
11
|
+
convert(DateTime.now, latitude, longitude, tz)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.convert(date_time, latitude, longitude, tz)
|
15
|
+
yesterday = SolarEventCalculator.new(date_time.to_date - 1, latitude, longitude)
|
16
|
+
today = SolarEventCalculator.new(date_time.to_date, latitude, longitude)
|
17
|
+
tomorrow = SolarEventCalculator.new(date_time.to_date + 1, latitude, longitude)
|
18
|
+
|
19
|
+
sunset_yesterday = yesterday.compute_official_sunset(tz)
|
20
|
+
sunrise_today = today.compute_official_sunrise(tz)
|
21
|
+
sunset_today = today.compute_official_sunset(tz)
|
22
|
+
sunrise_tomorrow = tomorrow.compute_official_sunrise(tz)
|
23
|
+
|
24
|
+
if date_time < sunrise_today
|
25
|
+
start, finish = sunset_yesterday, sunrise_today
|
26
|
+
start_hour = 18
|
27
|
+
elsif date_time < sunset_today
|
28
|
+
start, finish = sunrise_today, sunset_today
|
29
|
+
start_hour = 6
|
30
|
+
else
|
31
|
+
start, finish = sunset_today, sunrise_tomorrow
|
32
|
+
start_hour = 18
|
33
|
+
end
|
34
|
+
|
35
|
+
seconds = (start_hour + (date_time - start).to_f / (finish - start) * 12) * 60 * 60
|
36
|
+
|
37
|
+
fractional = seconds - seconds.floor
|
38
|
+
seconds = seconds.floor
|
39
|
+
minutes = seconds / 60
|
40
|
+
seconds -= minutes * 60
|
41
|
+
hours = minutes / 60
|
42
|
+
minutes -= hours * 60
|
43
|
+
hours -= 24 if hours >= 24
|
44
|
+
|
45
|
+
NewTime.new(hours, minutes, seconds, fractional)
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_s
|
49
|
+
if hours > 12
|
50
|
+
"%i:%02i pm" % [hours - 12, minutes]
|
51
|
+
else
|
52
|
+
"%i:%02i am" % [hours, minutes]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/new_time.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'new_time/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "new_time"
|
8
|
+
spec.version = NewTime::VERSION
|
9
|
+
spec.authors = ["Matthew Landauer"]
|
10
|
+
spec.email = ["matthew@oaf.org.au"]
|
11
|
+
spec.summary = "A new kind of time that anchors you to the movement of the sun"
|
12
|
+
spec.description = "A new kind of time"
|
13
|
+
spec.homepage = 'https://github.com/mlandauer/new_time'
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake", '~> 0'
|
23
|
+
|
24
|
+
spec.add_dependency "RubySunrise", '~> 0'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: new_time
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matthew Landauer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-31 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.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: RubySunrise
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A new kind of time
|
56
|
+
email:
|
57
|
+
- matthew@oaf.org.au
|
58
|
+
executables:
|
59
|
+
- new_time
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- .ruby-version
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/new_time
|
70
|
+
- lib/new_time.rb
|
71
|
+
- lib/new_time/version.rb
|
72
|
+
- new_time.gemspec
|
73
|
+
homepage: https://github.com/mlandauer/new_time
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.2.0
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: A new kind of time that anchors you to the movement of the sun
|
97
|
+
test_files: []
|