ukclockchange 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 258a1e22aa346fa43815aad8ab9b5f097683294874ec3cc8f3f7da95f7864f8c
4
+ data.tar.gz: bba3889792607c15db0ddb18ad271e3745131b091fbc7a297a2d67ff4a3e597d
5
+ SHA512:
6
+ metadata.gz: 1c30453b97624645e37077b147bdb8626db64c3842f96d8f39bbb0b9a62f47c0c9981ec57d272a9c9d6096f78b86930a17352ee1a2267053ecfdad291977ba51
7
+ data.tar.gz: ce0dac1e6a3f14ee8851cd3becade7d10a8e3c330a03fd6cd3c227253cf86b1768818a56123d9ebf8419dc60ef9ef8fa9b2b3d2392b7ba9add98c13f2bc356a8
Binary file
Binary file
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: ukclockchange.rb
4
+
5
+ require 'chronic_cron'
6
+ require 'date'
7
+ require 'human_speakable'
8
+ require 'chronic_duration'
9
+
10
+
11
+ module HumanizeDate
12
+
13
+ refine Date do
14
+ def humanize()
15
+ HumanSpeakable.format_date(self)
16
+ end
17
+ end
18
+ end
19
+
20
+
21
+ class UKClockChange
22
+ using HumanizeDate
23
+
24
+ def self.next()
25
+ Time.now.dst? ? self.back : self.forward
26
+ end
27
+
28
+ def self.back()
29
+ clockchange()
30
+ end
31
+
32
+ def self.forward()
33
+ clockchange("last Sunday in March at 1am")
34
+ end
35
+
36
+ def self.clockchange(s="last Sunday in October at 2am")
37
+
38
+ t = ChronicCron.new(s).to_time
39
+ seconds = (t - Time.now).to_i
40
+ days = (t.to_date - Time.now.to_date).to_i
41
+
42
+ {
43
+ change: s =~ /October/ ? :back : :forward,
44
+ date: t.to_date,
45
+ days_remaining: days,
46
+ countdown_duration: ChronicDuration.output(seconds, units: 2),
47
+ formatted_date: t.to_date.humanize
48
+ }
49
+ end
50
+ end
51
+
52
+ if __FILE__ == $0 then
53
+ h = UKClockChange.next
54
+ puts "The clocks go %s %s." % [h[:change], h[:formatted_date]]
55
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ukclockchange
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
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAxMDA5MTExMDM3WhcN
15
+ MjExMDA5MTExMDM3WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCnWnML
17
+ J6aOF9cWBObfOqz4OzQZm0y86+xQlo4le8jKql6pCNh3q6qH71weh9Vi4YZu2oCC
18
+ 5LHzrC7YVacUvDw9hgPqc6snFum6Rrojk9T7SjLnwjRg+rPqfQhu7XpPrXaUJaYk
19
+ IMUBK4eH7XG1nBeUPZDKZ+L32KqjZMdvG61izaDZDlr/S4VXK1ei0vqg9Uu1TBLc
20
+ isjzhRMkDI3AEGiLCvJLGCvXhdD6iJXiXH5P5VLJQE0s3e66OW0XOs71ruHhwnvh
21
+ n/a55O4GOl/bAffsNP6Ko/+h5IHShQIST/bnwjWiyrtogeBfpUCL/aJzoBPvHkM0
22
+ O5wIx5C1MT9elX0DoYvhYQu59O1I3LVGMWKcGVbAOz0FF+lpI3o3N7hV6TjxZFqW
23
+ GA2bNdZJpVl0jbK37Wt1laJdMAGgz4ZArTFcNv7awH09UUMtp2iEa7BIEejQVtMB
24
+ ZyGvVrQpCSZA+boRHfN9bTP3r144YxHfxSPDRWMPPgdzMzc9TZKffKsJDicCAwEA
25
+ AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUkdNt6UBU
26
+ yPBIqhCH2iNfOCMygAYwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
27
+ c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
28
+ BgkqhkiG9w0BAQsFAAOCAYEAPkt22SK2FTXhUwlyzHyV+NyVgI6bMDd3GjrKigIH
29
+ VyKrArDHrlrrNnvBwRwxh6lQHu5ZFqMsxMliJWwyG7jM9FGBcCPC/4Isfz76N3Oj
30
+ sCHUXe1cnAZZ8dCGHVvGWs75DKOrFnOerF4066lWwX/6cYzdZjYa31TRrtvpM5fg
31
+ VxFKz/MOD91y0k7zQaa/WRd5ngXY4WRn3qAzOS7eZslOY6d7tUyhx8v5coyTA6eQ
32
+ GeSfJA3fn6wAyl9Zvs2sxFN784i5uMDqD2efSjsyZCke2d+/2SXVVE3hQDoG4TQD
33
+ 2UlLqKf4De1uILSpYKAPhcz1mjD6DIZ5f4qxDHfEgMVKBmZg1HfblIIp4OAYQtMJ
34
+ jWrK12lbIChNNBIv+sUjScAyPUG54hbA5CSbonAdilId794SooasdpZvvfDjRFpn
35
+ PK7Uv4WI3WDaROLllML/qrfojkjdUKccZcRyCFB6K9DdpdkGzmkp7AMPz9qztyeJ
36
+ vHV37X6N9+YUmRElfF2Fa+/1
37
+ -----END CERTIFICATE-----
38
+ date: 2020-10-09 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: chronic_cron
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.6.0
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.6'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 0.6.0
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.6'
60
+ - !ruby/object:Gem::Dependency
61
+ name: chronic_duration
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.10'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.10.6
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.10'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 0.10.6
80
+ - !ruby/object:Gem::Dependency
81
+ name: human_speakable
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 0.2.0
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.2.0
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '0.2'
100
+ description:
101
+ email: james@jamesrobertson.eu
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - lib/ukclockchange.rb
107
+ homepage: https://github.com/jrobertson/ukclockchange
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubygems_version: 3.0.3
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Returns the date when the clocks in the UK go forward or backwards 1 hour.
130
+ test_files: []
Binary file