Skip to content

Date.RelativeFormatStyle is rounding up #774

@BrentMifsud

Description

@BrentMifsud

We recently switched over to using FormatStyles instead of Dateformatters.

I noticed some odd behavior with the relative date format style.

import Foundation

let date = Calendar.autoupdatingCurrent.date(byAdding: .second, value: 90, to: .now)!
let date2 = Calendar.autoupdatingCurrent.date(byAdding: .second, value: 89, to: .now)!
date.formatted(.relative(presentation: .numeric, unitsStyle: .wide)) // in 2 minutes
date2.formatted(.relative(presentation: .numeric, unitsStyle: .wide)) // in 1 minute

Is this the intended behaviour?

Using legacy RelativeDateFormatters, it says "in 1 minute" until you actually reach the 2 min mark

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions