Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
ee4047a7
Commit
ee4047a7
authored
17 years ago
by
rtoy
Browse files
Options
Downloads
Patches
Plain Diff
Trac ticket #9: parse-time mishandles invalid number of days in a
month Add check for valid number of days for the given month.
parent
70fdac9a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/parse-time.lisp
+30
-2
30 additions, 2 deletions
code/parse-time.lisp
with
30 additions
and
2 deletions
code/parse-time.lisp
+
30
−
2
View file @
ee4047a7
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
;;;
(
ext:file-comment
(
ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/parse-time.lisp,v 1.1
5
2007/0
4
/0
7
1
5:16:43
rtoy Exp $"
)
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/parse-time.lisp,v 1.1
6
2007/0
5
/0
2
1
2:47:24
rtoy Exp $"
)
;;;
;;;
;;; **********************************************************************
;;; **********************************************************************
...
@@ -599,6 +599,27 @@
...
@@ -599,6 +599,27 @@
(
truncate
form-value
100
)
(
truncate
form-value
100
)
(
setf
(
decoded-time-zone
parsed-values
)
(
-
(
+
hours
(
/
mins
60
))))))
(
setf
(
decoded-time-zone
parsed-values
)
(
-
(
+
hours
(
/
mins
60
))))))
(
defun
check-days-per-month
(
parsed-values
)
(
cond
((
=
(
decoded-time-month
parsed-values
)
2
)
;; February only has 28 days, except for leap years
(
flet
((
leap-year-p
(
y
)
;; Leap years are years divisible by 4. Except if
;; it's divisible by 100, in which case, only if
;; it's divisible by 400.
(
let
((
div-100
(
mod
y
100
))
(
div-4
(
mod
y
4
)))
(
if
(
zerop
div-100
)
(
zerop
(
mod
y
400
))
(
zerop
div-4
)))))
(
<=
(
decoded-time-day
parsed-values
)
(
if
(
leap-year-p
(
decoded-time-year
parsed-values
))
29
28
))))
((
member
(
decoded-time-month
parsed-values
)
'
(
4
6
9
11
))
;; These months only have 30 days
(
<=
(
decoded-time-day
parsed-values
)
30
))
(
t
t
)))
;;; Set-time-values uses the association list of symbols and values
;;; Set-time-values uses the association list of symbols and values
;;; to set the time in the decoded-time structure.
;;; to set the time in the decoded-time structure.
...
@@ -620,7 +641,14 @@
...
@@ -620,7 +641,14 @@
(
noon-midn
(
deal-with-noon-midn
form-value
parsed-values
))
(
noon-midn
(
deal-with-noon-midn
form-value
parsed-values
))
(
date-time-divider
0
)
(
date-time-divider
0
)
(
special
(
funcall
form-value
parsed-values
))
(
special
(
funcall
form-value
parsed-values
))
(
t
(
error
"Unrecognized symbol in form list: ~A."
form-type
))))))
(
t
(
error
"Unrecognized symbol in form list: ~A."
form-type
)))))
;; Some simple sanity checks, like does the given month have that
;; many days? Is it a leap year?
(
unless
(
check-days-per-month
parsed-values
)
(
error
"Invalid number of days (~D) for month ~D in ~D"
(
decoded-time-day
parsed-values
)
(
decoded-time-month
parsed-values
)
(
decoded-time-year
parsed-values
))))
(
defun
parse-time
(
time-string
&key
(
start
0
)
(
end
(
length
time-string
))
(
defun
parse-time
(
time-string
&key
(
start
0
)
(
end
(
length
time-string
))
(
error-on-mismatch
nil
)
(
error-on-mismatch
nil
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment