british_suntimes 0.1.1 → 0.2.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -2
- data/lib/british_suntimes.rb +32 -8
- metadata +21 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c5bd7fbe035ba01409e39e038fa49d88efab4b9
|
4
|
+
data.tar.gz: 9d61e58456b71a6dc47ad06afae313c19b19a45d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a9ed3142cad3571762c1b97119752ef1ff5669e04650c5e0ee10a5199c62e73dafa2d871c32df7c33d7cc6abe5f01d4b76dcc0bf84ae6fef4c1978817f7063e
|
7
|
+
data.tar.gz: 2de288110357ba6bdd75d1868517330e633d1140d7cd84ba0bcfaa95295eae6a5e04fd466ae7288b4d600b06ac4075ff10b1948dfd3084980a711303a41af62f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
�
|
1
|
+
���a������=����,2-m��,����,�� �Wx�uo�{���3��s�e��7@)��F��Ȝ=1 ���9}�^�b�̒� p8 }J9V<2����-��3!�md�@Hx�
|
2
|
+
�h���1�m��uXQYKI(Ӎ�������W5���_��Bfe��<��(,��(q��rl��"s��}��<��������7C�=ɞ�bd��#�XQ{�\��u�1ѢZT���Ӫ���&
|
data/lib/british_suntimes.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# file: british_suntimes.rb
|
4
4
|
|
5
5
|
|
6
|
+
require 'dynarex'
|
6
7
|
require 'geocoder'
|
7
8
|
require 'chronic_cron'
|
8
9
|
require 'solareventcalculator'
|
@@ -11,10 +12,10 @@ require 'solareventcalculator'
|
|
11
12
|
|
12
13
|
class BritishSuntimes
|
13
14
|
|
14
|
-
attr_reader :to_h, :bst_start, :bst_end
|
15
|
+
attr_reader :to_h, :bst_start, :bst_end, :to_dx
|
15
16
|
|
16
17
|
|
17
|
-
def initialize(year=
|
18
|
+
def initialize(year=Date.today.year.to_s, location: 'edinburgh')
|
18
19
|
|
19
20
|
a = (Date.parse(year + ' Jan')...Date.parse(year.succ + ' Jan')).to_a
|
20
21
|
g = Geocoder.search(location)
|
@@ -33,22 +34,45 @@ class BritishSuntimes
|
|
33
34
|
|
34
35
|
# alter the times for British summertime
|
35
36
|
|
36
|
-
|
37
|
+
@bst_start = ChronicCron.new('last sunday in March at 1am',
|
37
38
|
Time.local(year)).to_date
|
38
|
-
|
39
|
+
@bst_end = ChronicCron.new('last sunday in October at 2am',
|
39
40
|
Time.local(year)).to_date
|
40
41
|
|
41
|
-
@bst_start, @bst_end = d1, d2
|
42
42
|
|
43
|
-
(
|
43
|
+
(@bst_start...@bst_end).to_a.each do |d|
|
44
44
|
t1, t2 = times[d.strftime("%d %b")].map {|x| Time.parse(x)}
|
45
45
|
t1 += 60 * 60; t2 += 60 * 60
|
46
46
|
times[d.strftime("%d %b")] = [t1.strftime("%H:%M"), t2.strftime("%H:%M")]
|
47
47
|
end
|
48
48
|
|
49
|
-
@to_h = times
|
50
|
-
|
49
|
+
@year, @location, @to_h = year, location, times
|
50
|
+
@to_dx = build_dx()
|
51
|
+
|
51
52
|
end
|
53
|
+
|
54
|
+
# exports the sun times to a raw Dynarex file
|
55
|
+
#
|
56
|
+
def export(filename=@location + "-suntimes-#{@year}.txt")
|
57
|
+
File.write filename, @to_dx.to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def build_dx()
|
63
|
+
|
64
|
+
dx = Dynarex.new 'times[title, tags, desc, bst_start, ' +
|
65
|
+
'bst_end]/day(date, sunrise, sunset)'
|
66
|
+
dx.title = @location + " sunrise sunset times " + @year
|
67
|
+
dx.tags = @location + " times sunrise sunset %s" % [@year]
|
68
|
+
dx.delimiter = ' # '
|
69
|
+
dx.bst_start, dx.bst_end = @bst_start.to_s, @bst_end.to_s
|
70
|
+
dx.desc = 'Adjusted for British summertime'
|
71
|
+
|
72
|
+
@to_h.each {|k,v| dx.create date: k, sunrise: v[0], sunset: v[1] }
|
73
|
+
|
74
|
+
dx
|
75
|
+
end
|
52
76
|
|
53
77
|
end
|
54
78
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: british_suntimes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -32,6 +32,26 @@ cert_chain:
|
|
32
32
|
-----END CERTIFICATE-----
|
33
33
|
date: 2018-03-09 00:00:00.000000000 Z
|
34
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
|
35
55
|
- !ruby/object:Gem::Dependency
|
36
56
|
name: geocoder
|
37
57
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|