summaryrefslogtreecommitdiffstats
path: root/library/clock.tcl
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2004-12-29 20:57:25 (GMT)
committerKevin B Kenny <kennykb@acm.org>2004-12-29 20:57:25 (GMT)
commitf68ab6508b8355f713be6c3005204bbab14717aa (patch)
tree443fafc914ab6f557d09f08d00406daa7772ee6e /library/clock.tcl
parent3c1e7bd70247b897a1e6f47d8fcb6d50de880aea (diff)
downloadtcl-f68ab6508b8355f713be6c3005204bbab14717aa.zip
tcl-f68ab6508b8355f713be6c3005204bbab14717aa.tar.gz
tcl-f68ab6508b8355f713be6c3005204bbab14717aa.tar.bz2
bugs 1090413, 1092789 fixed
Diffstat (limited to 'library/clock.tcl')
-rw-r--r--library/clock.tcl21
1 files changed, 13 insertions, 8 deletions
diff --git a/library/clock.tcl b/library/clock.tcl
index 0a872ba..d47429c 100644
--- a/library/clock.tcl
+++ b/library/clock.tcl
@@ -13,7 +13,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: clock.tcl,v 1.12 2004/11/30 15:45:04 kennykb Exp $
+# RCS: @(#) $Id: clock.tcl,v 1.13 2004/12/29 20:57:28 kennykb Exp $
#
#----------------------------------------------------------------------
@@ -4419,6 +4419,14 @@ proc ::tcl::clock::GetJulianDayFromEraYearMonthDay { date } {
set year [dict get $date year]
}
}
+
+ # If month is out of range, reduce modulo 12 and adjust year accordingly.
+
+ set month [expr { [dict get $date month] - 1 }]
+ incr year [expr { $month / 12 }]
+ set month [expr { ( $month % 12 ) + 1 }]
+ dict set date era CE; dict set date year $year; dict set date month $month
+
set ym1 [expr { $year - 1 }]
# Try the Gregorian calendar first.
@@ -4428,9 +4436,9 @@ proc ::tcl::clock::GetJulianDayFromEraYearMonthDay { date } {
+ [dict get $date dayOfMonth]
+ ( [IsGregorianLeapYear $date] ?
[lindex $DaysInPriorMonthsInLeapYear \
- [expr { [dict get $date month] - 1}]]
+ [expr { $month - 1}]]
: [lindex $DaysInPriorMonthsInCommonYear \
- [expr { [dict get $date month] - 1}]] )
+ [expr { $month - 1}]] )
+ ( 365 * $ym1 )
+ ( $ym1 / 4 )
- ( $ym1 / 100 )
@@ -4445,9 +4453,9 @@ proc ::tcl::clock::GetJulianDayFromEraYearMonthDay { date } {
+ [dict get $date dayOfMonth]
+ ( ( $year % 4 == 0 ) ?
[lindex $DaysInPriorMonthsInLeapYear \
- [expr { [dict get $date month] - 1}]]
+ [expr { $month - 1}]]
: [lindex $DaysInPriorMonthsInCommonYear \
- [expr { [dict get $date month] - 1}]] )
+ [expr { $month - 1}]] )
+ ( 365 * $ym1 )
+ ( $ym1 / 4 ) }]
}
@@ -4483,9 +4491,6 @@ proc ::tcl::clock::GetJulianDayFromEraYearMonthDay { date } {
proc ::tcl::clock::GetJulianDayFromEraYearDay { date } {
- variable DaysInPriorMonthsInCommonYear
- variable DaysInPriorMonthsInLeapYear
-
# Get absolute year number from the civil year
switch -exact [dict get $date era] {