mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-16 18:25:11 -06:00
Bugzilla 790526 Correct weeknum calculator
This change will fix 'num-of-weeks-since-1/jan/1970' which formerly used quotient to remove the fractional part of the division. For negative values of num-of-weeks, the number is truncated in the wrong direction (i.e. towards 0). This change uses floor instead to ensure the num-of-weeks found is the nearest integer LESS than the fractional number.
This commit is contained in:
parent
335165104b
commit
33a7bb73db
@ -64,9 +64,8 @@
|
||||
(+ (tm:wday datevec) 1))
|
||||
;; jan 1 == 1
|
||||
(define (gnc:date-get-week datevec)
|
||||
(gnc:date-to-week (gnc:timepair->secs
|
||||
(gnc:timepair-start-day-time
|
||||
(gnc:date->timepair datevec)))))
|
||||
(gnc:date-to-week (gnc:time64-start-day-time
|
||||
(gnc-mktime datevec))))
|
||||
|
||||
(define (gnc:date-get-year-day datevec)
|
||||
(+ (tm:yday datevec) 1))
|
||||
@ -235,7 +234,7 @@
|
||||
(/ (- (/ (/ caltime 3600.0) 24) 3) 7))
|
||||
|
||||
(define (gnc:date-to-week caltime)
|
||||
(quotient (- (quotient caltime 86400) 3) 7))
|
||||
(floor (/ (- (/ caltime 86400) 3) 7)))
|
||||
|
||||
;; convert a date in seconds since 1970 into # of days since Feb 28, 1970
|
||||
;; ignoring leap-seconds
|
||||
|
Loading…
Reference in New Issue
Block a user