Bugzilla@Mozdev – Bug 26307
Extend dates variables with offset parameter (+ / - n days)
Last modified: 2018-07-04 11:43:48
You need to log in before you can comment on or make changes to this bug.
It is suggested to introduce a new variable to add future dates in new (and reply and forwarded if possible) e-mails for, e.g., setting deadlines. The future date could be calculated from the date the e-mail is sent possibly by adding a number for the days until deadline. For example: %datelocal(14)% would create a deadline 2 weeks after the sending date.
I was thinking about whether a date switch modification function could be used to do arithmetics on any date field - even the "atomic" ones, such as from this [terribly long, inherited from the original Addon] list: %A% = Day of Week (Friday) %a% = Day of Week (Fri.) %B% = Month (January) %b% = Month (Jan.) %d% = Day of Month (01 to 31) - with leading zero %e% = Day of Month (1 to 31) %m% = Month (01 to 12) - with leading zero %n% = Month (1 to 12) %Y% = Year (1970) %M% = Minute (00 to 59) %S% = Second (00 to 59) %H% = Hour, 24-Hour Format (00 to 23) - with leading zero %k% = Hour, 24-Hour Format (0 to 23) %I% = Hour, 12-Hour Format (01 to 12) - with leading zero %l% = Hour, 12-Hour Format (1 to 12) We already have a "global modifier" for times, which is %X:=sent% (which switches the date from current local time to the date of when the replied-to email is sent) We could have something like %X:=calculated(+2)% or similar which could act as a global switch for adding 2 days to any date field displayed in the template?
Here is a test template - note that the statement %X:=calculated(0)% should be used to reset the numeral day offset, otherwise it will be repeated on every date variable <p>Hello %from(firstname)%,</p> <h2>Test for Deadline</h2> <h3>Current date</h3> <p> %X:=today% %X:=calculated(1)% it will expire on %dateshort% (today+1) [ %e%.%n%.%Y% ] <br> %X:=today% %X:=calculated(0)% This Email was created on %dateshort% (today) [ %e%.%n%.%Y% ]<br> </p> <h3>Sent date</h3> <p>You have 1 week from your Send Date, until<br> %X:=sent% %X:=calculated(7)% %dateshort% [ %e%.%n%.%Y% ] <br> %X:=sent% %X:=calculated(0)% Sent on: %dateshort% <br> </p>
Created an attachment (id=8311) [details] 1.5 prerelease 26
(From update of attachment 8311 [details]) Adds the feature for adding / subtracting day arithmetics. Syntax: %X:=calculated(n)% n = number of days, e.g. n = 7 for adding a week. will modify all following date variables to result in the calculated date.
Created an attachment (id=8312) [details] 1.5 prerelease 55 In this version the X:=calculated variable can also work on New Emails (and not just Reply / Forward)
(In reply to comment #5) > Created an attachment (id=8312) [details] [details] > 1.5 prerelease 55 > > In this version the X:=calculated variable can also work on New Emails (and not > just Reply / Forward) > An "hours" offset was suggested for having deadlines. Ti could be added as second parameter, such as %X:=calculated(n,x)% where x = h:m h = offset in hours m = offset in minutes for example: %X:=calculated(7,6:30)% this would add 7 days and 6 hours 30 minutes to the time.
Setting to Resolved Fixed with official Release 1.5
Reopening for adding the time offset parameters in the next version
Created an attachment (id=8497) [details] 1.6 prerelease 86 Added second parameter MM:SS To add an offset of 2 days, 5 hours and 30 minutes %X:=calculated(2,5:30)% To reset for the rest of the Email simply add %X:=calculated(0)% This can be combined with the usual switches %X:=sent% %X:=today%
Created an attachment (id=8498) [details] Stationery / HTML Template This is a template Email for testing the date variables behavior. You can either paste the source code into a HTML view (use ThunderHTMLEdit for this) or add it as a Stationery Template.