File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,33 @@ contract DssExec {
5353 return SpellAction (action).officeHours ();
5454 }
5555
56+ function nextCastTime () external view returns (uint256 castTime ) {
57+ require (eta != 0 , "DssExec/spell-not-scheduled " );
58+ castTime = block .timestamp > eta ? block .timestamp : eta; // Any day at XX:YY
59+
60+ if (SpellAction (action).officeHours ()) {
61+ uint256 day = (castTime / 1 days + 3 ) % 7 ;
62+ uint256 hour = castTime / 1 hours % 24 ;
63+ uint256 minute = castTime / 1 minutes % 60 ;
64+ uint256 second = castTime % 60 ;
65+
66+ if (day >= 5 ) {
67+ castTime += (6 - day) * 1 days ; // Go to Sunday XX:YY
68+ castTime += (24 - hour + 14 ) * 1 hours ; // Go to 14:YY UTC Monday
69+ castTime -= minute * 1 minutes + second; // Go to 14:00 UTC
70+ } else {
71+ if (hour >= 21 ) {
72+ if (day == 4 ) castTime += 2 days ; // If Friday, fast forward to Sunday XX:YY
73+ castTime += (24 - hour + 14 ) * 1 hours ; // Go to 14:YY UTC next day
74+ castTime -= minute * 1 minutes + second; // Go to 14:00 UTC
75+ } else if (hour < 14 ) {
76+ castTime += (14 - hour) * 1 hours ; // Go to 14:YY UTC same day
77+ castTime -= minute * 1 minutes + second; // Go to 14:00 UTC
78+ }
79+ }
80+ }
81+ }
82+
5683 // @param _description A string description of the spell
5784 // @param _expiration The timestamp this spell will expire. (Ex. now + 30 days)
5885 // @param _spellAction The address of the spell action
You can’t perform that action at this time.
0 commit comments