Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

NSDate(MGLAdditions) turns seconds into nanoseconds #8264

Closed

Description

@1ec5

MGLDurationInSecondsFromTimeInterval() converts an NSTimeInterval (measured in seconds) into an mbgl::Duration (measured in nanoseconds), but MGLTimeIntervalFromDurationInSeconds() reinterprets an mbgl::Duration (measured in nanoseconds) as an NSTimeInterval without changing its value. As a result, these functions don’t round-trip and -[MGLStyle transitionDuration] and -[MGLStyle transitionDelay] return the wrong values. We should fix MGLTimeIntervalFromDurationInSeconds() to convert back into seconds. This page has examples for working with duration. We should also add a unit test to ensure round-tripping.

Additionally, the functions’ names incorrectly imply that mbgl::Duration is measured in seconds. They should be renamed MGLDurationFromTimeInterval() and MGLTimeIntervalFromDuration(), respectively.

Finally, #5980 declared and defined these functions within @interface and @implementation blocks, as though they were category methods, but they aren’t even methods in the first place. The NSDate(MGLAdditions) category should be removed, because these functions have nothing to do with NSDate. (These functions should remain in NSDate+MGLAdditions.h, because they relate to NSTimeInterval, which is declared in NSDate.h.)

/cc @fabian-guerra @incanus

Activity

  1. added
    iOS
    macOS
    on Mar 3, 2017
  2. added this to the ios-v3.5.0 milestone on Mar 3, 2017
  3. 1ec5 commented on Mar 3, 2017

    @1ec5
    ContributorAuthor

    MGLDurationInSecondsFromTimeInterval() has quite a bit of history:

    Not to point any blame – the naming made sense at the time, but it’s a good thing that we can finally remove “in seconds”!

  4. self-assigned this
    on Mar 3, 2017
  5. jfirebaugh commented on Mar 6, 2017

    @jfirebaugh
    Contributor

    #8276 addressed the above issues but introduced others (https://github.com/mapbox/mapbox-gl-native/pull/8276/files#r104329402). Keeping this open until those are resolved.

  6. jfirebaugh commented on Mar 9, 2017

    @jfirebaugh
    Contributor

    Fixed in #8290.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugiOSmacOS

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions