Fixes #262
This commit is contained in:
parent
7a684f6cb6
commit
924831f3e4
@ -447,7 +447,7 @@ getSheetNewR tid ssh csh = do
|
|||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
let template = case lastSheets of
|
let template = case lastSheets of
|
||||||
((Entity {entityVal=Sheet{..}}):_) ->
|
((Entity {entityVal=Sheet{..}}):_) ->
|
||||||
let addTime = addWeeks $ max 1 $ succ $ weekDiff sheetActiveTo now
|
let addTime = addWeeks $ max 1 $ weeksToAdd sheetActiveTo now
|
||||||
in Just $ SheetForm
|
in Just $ SheetForm
|
||||||
{ sfName = stepTextCounterCI sheetName
|
{ sfName = stepTextCounterCI sheetName
|
||||||
, sfDescription = sheetDescription
|
, sfDescription = sheetDescription
|
||||||
|
|||||||
@ -6,7 +6,7 @@ module Handler.Utils.DateTime
|
|||||||
, validDateTimeFormats, dateTimeFormatOptions
|
, validDateTimeFormats, dateTimeFormatOptions
|
||||||
, formatTimeMail
|
, formatTimeMail
|
||||||
, addOneWeek, addWeeks
|
, addOneWeek, addWeeks
|
||||||
, weekDiff
|
, weekDiff, weeksToAdd
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
@ -150,5 +150,15 @@ weekDiff old new = dayDiff `div` 7
|
|||||||
dayNew = utctDay new
|
dayNew = utctDay new
|
||||||
dayDiff = diffDays dayNew dayOld
|
dayDiff = diffDays dayNew dayOld
|
||||||
|
|
||||||
|
weeksToAdd :: UTCTime -> UTCTime -> Integer
|
||||||
|
-- ^ Number of weeks needed to add so that first
|
||||||
|
-- time occurs later than second time
|
||||||
|
-- (loop avoids off-by-one error with weekDiff corner cases)
|
||||||
|
weeksToAdd old new = loop 0 old
|
||||||
|
where
|
||||||
|
loop n t
|
||||||
|
| t > new = n
|
||||||
|
| otherwise = loop (succ n) (addOneWeek t)
|
||||||
|
|
||||||
|
|
||||||
-- addOneTerm? -> Move Handler.Utils.DateTime
|
-- addOneTerm? -> Move Handler.Utils.DateTime
|
||||||
|
|||||||
Reference in New Issue
Block a user