Skip to content

CalDateTime.AddDuration vs. CalDateTime.AddDay #849

@axunonb

Description

@axunonb

Describe the bug
CalDateTime.Add(Duration.FromDays(1) and CalDateTime.AddDay(1) do not return the same result.

To Reproduce

[Test]
public void AddOneDay()
{
    // Start Time: March 29, 2025, at 02:30 CET.
    // DST transition on March 30, 2025 at 02:00
    var dt = new CalDateTime(2025, 3, 29, 2, 30, 0, tzId: "Europe/Berlin");

    var resultFromDuration = dt.Add(Duration.FromDays(1));
    var resultAddDays = dt.AddDays(1);

    Assert.That(resultFromDuration.Value, Is.EqualTo(resultAddDays.Value));
}

Same with other arithmetic operations with nominal values.

Expected behavior
Results should be equal.

Environment:

  • OS: Windows 11
  • .NET version: NET8.0
  • ical.net version: 5.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions