This repository was archived by the owner on Oct 8, 2024. It is now read-only.
File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,33 @@ contract DssExec {
53
53
return SpellAction (action).officeHours ();
54
54
}
55
55
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
+
56
83
// @param _description A string description of the spell
57
84
// @param _expiration The timestamp this spell will expire. (Ex. now + 30 days)
58
85
// @param _spellAction The address of the spell action
You can’t perform that action at this time.
0 commit comments