summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2017-10-02 16:59:40 +0200
committerHarald Eilertsen <haraldei@anduin.net>2017-10-02 16:59:40 +0200
commite505fa45eded7a1a15c8362350e878688c229d5f (patch)
tree25c4514a82d1d6dc6b6fe25263defa4428e500cf
parentd91338c647ef511d55a6be7493fca950a0c5fb46 (diff)
downloadnorsk-urskog-registrations-e505fa45eded7a1a15c8362350e878688c229d5f.tar.gz
norsk-urskog-registrations-e505fa45eded7a1a15c8362350e878688c229d5f.tar.bz2
norsk-urskog-registrations-e505fa45eded7a1a15c8362350e878688c229d5f.zip
Try to get better info if config can't be parsed.
-rw-r--r--lib/registration.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/registration.rb b/lib/registration.rb
index bfcf903..4f2db17 100644
--- a/lib/registration.rb
+++ b/lib/registration.rb
@@ -32,8 +32,15 @@ def create_pdf_file_name(band)
filename = "#{Date.today.iso8601}-#{sanitize(band.name)}-#{sanitize(band.city)}.pdf"
end
+def parse_date(str)
+ Date.parse(str)
+rescue TypeError => e
+ $stderr << "Invalid date specified: " << str
+ raise
+end
+
def accept_registrations(settings)
- start_date = Date.parse(settings.accept_registrations[:start])
- end_date = Date.parse(settings.accept_registrations[:stop])
+ start_date = parse_date(settings.accept_registrations[:start])
+ end_date = parse_date(settings.accept_registrations[:stop])
start_date <= Date.today && end_date > Date.today
end