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:
Noko 2019-10-27 18:21:55 -05:00 committed by Astrid
parent 545e8df6a7
commit eb5fe7d6a4

View File

@ -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;