babalae/better-genshin-impact · warning · ArgumentException
无效的分钟值: {minute},必须是 0-59 之间的整数字符
Error message
无效的分钟值: {minute},必须是 0-59 之间的整数字符 What it means
Thrown by the int overload of SetTime when minute is outside the inclusive range [0, 59]. The game clock only supports valid minute values within a standard 60-minute hour.
Source
Thrown at BetterGenshinImpact/Core/Script/Dependence/Genshin.cs:500
/// <returns></returns>
public async Task WonderlandCycle()
{
await new EnterAndExitWonderlandJob().Start(CancellationContext.Instance.Cts.Token);
}
/// <summary>
/// 调整时间
/// </summary>
/// <param name="hour">目标小时(0-24)</param>
/// <param name="minute">目标分钟(0-59)</param>
/// <param name="skip">是否跳过动画(默认为否)</param>
/// <returns></returns>
public async Task SetTime(int hour, int minute, bool skip = false)
{
if ( hour < 0 || hour > 24)
throw new ArgumentException($"无效的小时值: {hour},必须是 0-24 之间的整数字符", nameof(hour));
if (minute < 0 || minute > 59)
throw new ArgumentException($"无效的分钟值: {minute},必须是 0-59 之间的整数字符", nameof(minute));
await new SetTimeTask().Start(hour, minute, CancellationContext.Instance.Cts.Token, skip);
}
/// <summary>
/// 调整时间
/// </summary>
/// <param name="hour">目标小时(0-24的字符类型)</param>
/// <param name="minute">目标分钟(0-59的字符类型)</param>
/// <param name="skip">是否跳过动画(默认为否)</param>
/// <returns></returns>
public async Task SetTime(string hour, string minute, bool skip = false)
{
if (!int.TryParse(hour, out var h) || h < 0 || h > 24)
throw new ArgumentException($"无效的小时值: {hour},必须是 0-24 之间的整数字符", nameof(hour));
if (!int.TryParse(minute, out var m) || m < 0 || m > 59)
throw new ArgumentException($"无效的分钟值: {minute},必须是 0-59 之间的整数字符", nameof(minute));
await new SetTimeTask().Start(h, m, CancellationContext.Instance.Cts.Token, skip);
}View on GitHub (pinned to a7cb36712d)
Solutions
- Clamp minute to [0, 59] before calling SetTime.
- If adding an offset, compute carry: hour += minute / 60; minute = minute % 60.
- Validate the value with an explicit range check and handle the error case gracefully.
Example fix
// before genshin.SetTime(baseHour, baseMinute + offset); // after var totalMinutes = baseMinute + offset; var finalHour = baseHour + totalMinutes / 60; var finalMinute = totalMinutes % 60; genshin.SetTime(Math.Clamp(finalHour, 0, 24), finalMinute);
Defensive patterns
Strategy: validation
Validate before calling
// Validate minute range before calling SetTime
if (minute < 0 || minute > 59)
throw new ArgumentOutOfRangeException(nameof(minute), minute, "Minute must be 0-59");
genshin.SetTime(hour, minute); Prevention
- Always clamp minute to [0, 59] before calling SetTime.
- When adding time offsets, carry overflow into the hour component.
- Use modulo for wrap-around: minute = (minute % 60 + 60) % 60.
When it happens
Trigger: Calling genshin.SetTime(hour, minute) with minute < 0 or minute > 59. Typically caused by unclamped arithmetic (e.g., minute = 65 after time addition without carry-over).
Common situations: Script adds minutes to a base time (baseMinute + offset) without handling carry into hours. Floating-point minute values cast to int produce unexpected ranges.
Related errors
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/3a41519654b90b9d.
Report an issue: GitHub.