british_suntimes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6e0842d09954148c6a884c8fad4094438564bda9
4
+ data.tar.gz: 82e712fd171b1a7536fd74e26cc550463c5b90e3
5
+ SHA512:
6
+ metadata.gz: 9137e3dc0130eb3464fdfdd96a7bb9b88ca758af473ca521d6701e8d7fb6350d6932576e3c578e4064c12192dabd0eeb54cd3693e3362f51c87bdfc044b8974f
7
+ data.tar.gz: ef9a918daa7119e75105eef66214cdb59ce3af8a348bd365af02971a25c15f6d1853e0e72f41077631898193d2eecdcb7cf37b66c6f8c76903753bd8d7cf044b
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: british_suntimes.rb
4
+
5
+
6
+ require 'dynarex'
7
+ require 'geocoder'
8
+ require 'chronic_cron'
9
+ require 'solareventcalculator'
10
+
11
+
12
+
13
+ class BritishSuntimes
14
+
15
+ attr_reader :to_h, :bst_start, :bst_end
16
+
17
+
18
+ def initialize(year= Date.today.year.to_s, location: 'edinburgh')
19
+
20
+ a = (Date.parse(year + ' Jan')...Date.parse(year.succ + ' Jan')).to_a
21
+ g = Geocoder.search(location)
22
+
23
+ times = a.inject({}) do |r, date|
24
+
25
+ calc = SolarEventCalculator.new(date, *g[0].coordinates)
26
+
27
+ a2 = %w(sunrise sunset).map do |event|
28
+ calc.method('compute_utc_official_'.+(event).to_sym).call\
29
+ .strftime("%H:%M")
30
+ end
31
+
32
+ r.merge(date.strftime("%d %b") => a2)
33
+ end
34
+
35
+ # alter the times for British summertime
36
+
37
+ d1 = ChronicCron.new('last sunday in March at 1am',
38
+ Time.local(year)).to_date
39
+ d2 = ChronicCron.new('last sunday in October at 2am',
40
+ Time.local(year)).to_date
41
+
42
+ @bst_start, @bst_end = d1, d2
43
+
44
+ (d1...d2).to_a.each do |d|
45
+ t1, t2 = times[d.strftime("%d %b")].map {|x| Time.parse(x)}
46
+ t1 += 60 * 60; t2 += 60 * 60
47
+ times[d.strftime("%d %b")] = [t1.strftime("%H:%M"), t2.strftime("%H:%M")]
48
+ end
49
+
50
+ @to_h = times
51
+
52
+ end
53
+
54
+ end
55
+
56
+
57
+ if __FILE__ == $0 then
58
+
59
+ h = BritishSuntimes.new.to_h
60
+
61
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: british_suntimes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwMzA4MjMyMjA5WhcN
15
+ MTkwMzA4MjMyMjA5WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCiAALr
17
+ RUV3gWaErxprpgvbKvK0BXBDbt7bg2g6yT4k7VmZLg3jSxIcYw4kg5OUQou+Rawo
18
+ geosw2OlYPwhWk/Mi6BSUOk8oxPplPBjSiFeAVPllcl+c/wDVPBOw5UIyAORRtqO
19
+ /jPjpOSU/rWsI29+TlyW3xJyrygZQq7Qt6FyxNn0d4JNi5muCfhDeW0eoYA7SP2p
20
+ U8HH/wNn2ywYALtsLBGAVsgPvklyjJPVWiRSyIvvsjzbw7A5FShZyzHjks5vYesi
21
+ 81j3L+nXsKdUxAJvTsF7pla3R38S77Ofzpu0e+/oLe9YcsyfJ8mEMHaQ8ZQpwT/d
22
+ XYVXASZE0nF0MV+/AgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
23
+ HQYDVR0OBBYEFJswy1odtxLSCTl/h63FVI/I+bZHMCYGA1UdEQQfMB2BG2dlbW1h
24
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0ZXJAamFt
25
+ ZXNyb2JlcnRzb24uZXUwDQYJKoZIhvcNAQEFBQADggEBADDcd+EUEgN89jQnTJR9
26
+ h2HBjCEY7pi34Uvt7r6j0JQ1KdxiImCzuodCwhG/N7GdSvsbEz7NIiFYCGOpuz/P
27
+ bfG4Mgm5HvF23peANQb/4FsyLrTeU6kfVVX9Y4+fNzqvtoZcGFatwkd6HwTVeAcF
28
+ MADD6VocV947BlLDCnvXhItufSvlXBePeagBrHwU9Rn4ZlXRBqfY3ARgoKds4JOD
29
+ Uaa19ssID793D5r9XNEJaj4b71bc3ZV9xN5T7pjk6xR+qo9UDpbjjebNDmXyRF+k
30
+ 6NfdgdbEPoIwx9xSj/tJ26i0eNPJ53cC1rDinNZhk6WUm3t/kVCn79iPKg1SWhvl
31
+ /Zg=
32
+ -----END CERTIFICATE-----
33
+ date: 2018-03-08 00:00:00.000000000 Z
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: dynarex
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.7'
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 1.7.29
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '1.7'
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.7.29
55
+ - !ruby/object:Gem::Dependency
56
+ name: geocoder
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.4'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.4.6
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.4'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.4.6
75
+ - !ruby/object:Gem::Dependency
76
+ name: chronic_cron
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.3'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 0.3.7
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '0.3'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 0.3.7
95
+ - !ruby/object:Gem::Dependency
96
+ name: RubySunrise
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0.3'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 0.3.1
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '0.3'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 0.3.1
115
+ description:
116
+ email: james@jamesrobertson.eu
117
+ executables: []
118
+ extensions: []
119
+ extra_rdoc_files: []
120
+ files:
121
+ - lib/british_suntimes.rb
122
+ homepage: https://github.com/jrobertson/british_suntimes
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.6.13
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Generates the British sunrise and sunset times.
146
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ *�B�4p�d����u�>cic0h�e�c
2
+ �iћ�W�>��&8~�$3����beBw��P����d2���>�_%+(~K΅ZZ�߾P$!����M�>�Y!�=���ȧ?��6�;��$