Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

ParseTimeAsync Issues #193

Closed
Closed

Description

@codeacula

ParseTimeAsync calls ConvertToUtc on fuzzy results, but all current fuzzy parsers return DateTimeKind.Utc (via EnsureUtc), so providing userTimeZoneId has no effect for expressions like "at 3pm"/"tomorrow". This will schedule user-local times as if they were UTC. Consider having fuzzy parsers return DateTimeKind.Unspecified for user-local clock/date expressions (and only return UTC for relative durations), and/or pass a reference time in the user's timezone into the fuzzy parser so day boundaries (today/tomorrow) are interpreted correctly.

      var fuzzyValue = fuzzyResult.Value;

      // Many fuzzy parsers currently return DateTimeKind.Utc even for user-local wall-clock
      // expressions (e.g., "tomorrow at 3pm"). When a user timezone is provided, interpret
      // such values as local clock times in that timezone and convert to true UTC.
      if (!string.IsNullOrWhiteSpace(userTimeZoneId) && fuzzyValue.Kind == DateTimeKind.Utc)
      {
        try
        {
          var unspecifiedLocal = DateTime.SpecifyKind(fuzzyValue, DateTimeKind.Unspecified);
          var userTimeZone = TimeZoneInfo.FindSystemTimeZoneById(userTimeZoneId);
          var utcFromUserLocal = TimeZoneInfo.ConvertTimeToUtc(unspecifiedLocal, userTimeZone);
          return Result.Ok(utcFromUserLocal);
        }
        catch
        {
          // Fall back to existing conversion logic to avoid changing behavior on invalid
          // timezones or unexpected errors.
          var fallbackUtc = ConvertToUtc(fuzzyValue, userTimeZoneId);
          return Result.Ok(fallbackUtc);
        }
      }

      var utcFuzzy = ConvertToUtc(fuzzyValue, userTimeZoneId);

Originally posted by @Copilot in #182 (comment)

Activity

  1. changed the title [-]`ParseTimeAsync` calls `ConvertToUtc` on fuzzy results, but all current fuzzy parsers return `DateTimeKind.Utc` (via `EnsureUtc`), so providing `userTimeZoneId` has no effect for expressions like "at 3pm"/"tomorrow". This will schedule user-local times as if they were UTC. Consider having fuzzy parsers return `DateTimeKind.Unspecified` for user-local clock/date expressions (and only return UTC for relative durations), and/or pass a reference time in the user's timezone into the fuzzy parser so day boundaries (today/tomorrow) are interpreted correctly.[/-] [+]ParseTimeAsync Issues[/+] on Feb 23, 2026
  2. added this to the Viability milestone on Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggumsSomething isn't working

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions