Skip to content

DateTime wrapper rounds to nearest second #35

@sjanic

Description

@sjanic

Given this example

func testExample() throws {
  let start = DateTime(
    date: FHIRDate(string: "1990-08-17")!,
    time: FHIRTime(hour: 12, minute: 8, second: 20.99999),
    timeZone: TimeZone.current
  )
  print("Start date as json: \(start.description)")
  print("Start date as NSDate: \(start.nsDate)")
}

I get the following output

Start date as json: 1990-08-17T12:08:21+02:00
Start date as NSDate: 1990-08-17 10:08:20 +0000

I'm wondering why the DateTime rounds up to the nearest second (it has a precision of 4 decimals of milliseconds), when the NSDate doesn't. Is this an issue (it could potentially mean that something happen a second earlier/later then expected)?

I'm using Swift-SMART version 4.2.0

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