Mercurial > piecrust2
comparison piecrust/sources/posts.py @ 1127:4cc020ff2537
prepare: Fix crash when preparing new pages.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 28 Feb 2018 20:16:33 -0800 |
parents | 8adc27285d93 |
children | 1bb70ec2cb03 |
comparison
equal
deleted
inserted
replaced
1126:be550e1f6423 | 1127:4cc020ff2537 |
---|---|
172 raise Exception("Date offsets must be numbers.") | 172 raise Exception("Date offsets must be numbers.") |
173 else: | 173 else: |
174 try: | 174 try: |
175 year, month, day = [int(s) for s in date.split('/')] | 175 year, month, day = [int(s) for s in date.split('/')] |
176 except ValueError: | 176 except ValueError: |
177 raise Exception("Dates must be of the form: " | 177 raise Exception( |
178 "YEAR/MONTH/DAY.") | 178 "Dates must be of the form 'YEAR/MONTH/DAY', " |
179 "got '%s'." % | |
180 str(date)) | |
179 dt = datetime.date(year, month, day) | 181 dt = datetime.date(year, month, day) |
180 elif isinstance(date, datetime.datetime): | 182 elif isinstance(date, datetime.datetime): |
181 dt = datetime.date(date.year, date.month, date.day) | 183 dt = datetime.date(date.year, date.month, date.day) |
182 else: | 184 else: |
183 try: | 185 try: |