Allow frontpercent to accept time patterns in system timezone (#135)
The frontpercent command already accepted time patterns (e.g. 9pm), but these were always being interpreted as UTC regardless of the system's configured zone. Furthermore, the time wasn't being nudged to the previous day, so if you tried to do pk;s fp 6pm at 5pm UTC, it would complain about the date being in the future instead of just showing you since 6pm yesterday. The system zone is now respected and nudging enabled in the same manner as pk;sw move.
This commit is contained in:
parent
545e8df6a7
commit
eb5fe7d6a4
@ -190,7 +190,7 @@ namespace PluralKit.Bot.Commands
|
|||||||
|
|
||||||
var now = SystemClock.Instance.GetCurrentInstant();
|
var now = SystemClock.Instance.GetCurrentInstant();
|
||||||
|
|
||||||
var rangeStart = PluralKit.Utils.ParseDateTime(durationStr);
|
var rangeStart = PluralKit.Utils.ParseDateTime(durationStr, true, system.Zone);
|
||||||
if (rangeStart == null) throw Errors.InvalidDateTime(durationStr);
|
if (rangeStart == null) throw Errors.InvalidDateTime(durationStr);
|
||||||
if (rangeStart.Value.ToInstant() > now) throw Errors.FrontPercentTimeInFuture;
|
if (rangeStart.Value.ToInstant() > now) throw Errors.FrontPercentTimeInFuture;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user