relative_time icon indicating copy to clipboard operation
relative_time copied to clipboard

Day after tomorrow is not working correctly

Open bartdelange opened this issue 1 year ago • 1 comments

The code below is incorrectly suggesting that the second date in the list is occurring tomorrow. I am using rrules to generate the date instances and convert them with the timezone package.

    final now = tz.TZDateTime.now(tz.UTC);
    final startOfDay = tz.TZDateTime.from(
      DateTime(
        now.year,
        now.month,
        now.day,
      ),
      tz.local,
    ).toUtc();
    print(now);
    // -> flutter: 2024-02-08 17:33:55.557756Z
    print(widget.plant.wateringNotificationDates(startOfDay).take(3));
    // -> flutter: (2024-02-08 16:00:00.000Z, 2024-02-10 16:00:00.000Z, 2024-02-13 16:00:00.000Z)
    print(widget.plant.wateringNotificationDates(startOfDay).take(3).map((e) => e.toLocal().relativeTime(context)));
    // -> flutter: (1 hour ago, tomorrow, in 4 days)

bartdelange avatar Feb 08 '24 17:02 bartdelange

I'm running into the same issue - both dates that are tomorrow and the day after tomorrow return "tomorrow" when using relativeTime. Did you end up finding a fix or workaround?

sarlow avatar Jun 26 '24 06:06 sarlow