Skip to content

"the last Friday of this month" resolves to previous month (should be last Friday of the current month) #3199

@TarasFedorenkoFTV

Description

@TarasFedorenkoFTV

Describe the bug

Parsing "the last Friday of this month" in September 2025 returns August 29, 2025 (last Friday of the previous month) instead of September 26, 2025 (last Friday of this month).

To Reproduce

Set reference date to any day in September 2025 (e.g., 2025-09-23).

Run:

using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.DateTime;

var refDate = new DateTime(2025, 9, 23, 12, 0, 0); // local reference
var results = DateTimeRecognizer.RecognizeDateTime(
"the last Friday of this month",
Culture.English,
DateTimeOptions.None,
refDate
);

Inspect the resolution.

Expected behavior

"the last Friday of this month" (with “of this month”) should resolve to the final Friday of the current month (September 2025) → 2025-09-26.

Actual behavior

Returns 2025-08-29 (last Friday of the previous month).

Sample input/output

Input

"the last Friday of this month"

Actual resolution (simplified)

{ "type": "date", "value": "2025-08-29" }

Expected resolution

{ "type": "date", "value": "2025-09-26" }

Platform

Platform: .NET

Environment: NuGet package

Version: (e.g.) 1.8.0 (please confirm the exact version)

Additional context

Preliminary debugging suggests that "last" is matched by PreviousPrefixRegex and mapped to -1 in GetSwiftMonthOrYear, which shifts the computation to the previous month even when the utterance explicitly says "of this month".
Desired behavior: treat the pattern "the last of (this|current) month" as current month (swift = 0), then compute the final occurrence of that weekday within the month.

Possible direction

Add a high-priority rule that captures "the last {weekday} of (this|current) month" and resolves within the current month (no negative swift).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions