Bug 794030 - relative date functions compute wrong day of month

Convert > to < and rename month-length to month-days for consistency.
This commit is contained in:
Christopher Lam
2018-03-25 15:47:35 +08:00
parent 0c8c94eab0
commit a670238f80

View File

@@ -718,10 +718,10 @@
(set-tm:mon now 11)
(set-tm:year now (- (tm:year now) 1)))
(set-tm:mon now (- (tm:mon now) 1)))
(let ((month-length (gnc:days-in-month (+ (tm:mon now) 1)
(+ (tm:year now) 1900))))
(if (> month-length (tm:mday now))
(set-tm:mday now month-length))
(let ((month-days (gnc:days-in-month (+ (tm:mon now) 1)
(+ (tm:year now) 1900))))
(if (< month-days (tm:mday now))
(set-tm:mday now month-days))
(set-tm:isdst now -1)
(gnc:date->timepair now))))
@@ -734,7 +734,7 @@
(set:tm-mon now (- (tm:mon now) 3))
(let ((month-days (gnc:days-in-month (+ (tm:mon now) 1)
(+ (tm:year now) 1900))))
(if (> month-days (tm:mday now))
(if (< month-days (tm:mday now))
(set-tm:mday now month-days))
(set-tm:isdst now -1)
(gnc:date->timepair now))))
@@ -748,7 +748,7 @@
(set:tm-mon now (- (tm:mon now) 6))
(let ((month-days (gnc:days-in-month (+ (tm:mon now) 1)
(+ (tm:year now) 1900))))
(if (> month-days (tm:mday now))
(if (< month-days (tm:mday now))
(set-tm:mday now month-days))
(set-tm:isdst now -1)
(gnc:date->timepair now))))
@@ -757,8 +757,8 @@
(let ((now (gnc-localtime (current-time))))
(set:tm-year now (- (tm:year now) 1))
(let ((month-days (gnc:days-in-month (+ (tm:mon now) 1)
(+ (tm:year now) 1900))))
(if (> month-days (tm:mday now))
(+ (tm:year now) 1900))))
(if (< month-days (tm:mday now))
(set-tm:mday now month-days))
(set-tm:isdst now -1)
(gnc:date->timepair now))))
@@ -770,10 +770,10 @@
(set-tm:mon now 0)
(set-tm:year now (+ (tm:year now) 1)))
(set-tm:mon now (+ (tm:mon now) 1)))
(let ((month-length (gnc:days-in-month (+ (tm:mon now) 1)
(+ (tm:year now) 1900))))
(if (> month-length (tm:mday now))
(set-tm:mday now month-length))
(let ((month-days (gnc:days-in-month (+ (tm:mon now) 1)
(+ (tm:year now) 1900))))
(if (< month-days (tm:mday now))
(set-tm:mday now month-days))
(set-tm:isdst now -1)
(gnc:date->timepair now))))
@@ -783,10 +783,10 @@
(begin
(set:tm-mon now (- (tm:mon now) 9))
(set:tm-year now (+ (tm:year now) 1))
(set:tm-mon now (+ (tm:mon now) 3))))
(set:tm-mon now (+ (tm:mon now) 3))))
(let ((month-days (gnc:days-in-month (+ (tm:mon now) 1)
(+ (tm:year now) 1900))))
(if (> month-days (tm:mday now))
(if (< month-days (tm:mday now))
(set-tm:mday now month-days))
(set-tm:isdst now -1)
(gnc:date->timepair now))))
@@ -797,10 +797,10 @@
(begin
(set:tm-mon now (- (tm:mon now) 6))
(set:tm-year now (+ (tm:year now) 1))
(set:tm-mon now (+ (tm:mon now) 6))))
(set:tm-mon now (+ (tm:mon now) 6))))
(let ((month-days (gnc:days-in-month (+ (tm:mon now) 1)
(+ (tm:year now) 1900))))
(if (> month-days (tm:mday now))
(if (< month-days (tm:mday now))
(set-tm:mday now month-days))
(set-tm:isdst now -1)
(gnc:date->timepair now))))
@@ -809,8 +809,8 @@
(let ((now (gnc-localtime (current-time))))
(set:tm-year now (+ (tm:year now) 1))
(let ((month-days (gnc:days-in-month (+ (tm:mon now) 1)
(+ (tm:year now) 1900))))
(if (> month-days (tm:mday now))
(+ (tm:year now) 1900))))
(if (< month-days (tm:mday now))
(set-tm:mday now month-days))
(set-tm:isdst now -1)
(gnc:date->timepair now))))