TimestampedGlucoseEvent.swift 730 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // TimestampedGlucoseEvent.swift
  3. // RileyLink
  4. //
  5. // Created by Timothy Mecklem on 10/19/16.
  6. // Copyright © 2016 Pete Schwamb. All rights reserved.
  7. //
  8. import Foundation
  9. public struct TimestampedGlucoseEvent {
  10. public let glucoseEvent: GlucoseEvent
  11. public let date: Date
  12. public init(glucoseEvent: GlucoseEvent, date: Date) {
  13. self.glucoseEvent = glucoseEvent
  14. self.date = date
  15. }
  16. }
  17. extension TimestampedGlucoseEvent: DictionaryRepresentable {
  18. public var dictionaryRepresentation: [String: Any] {
  19. var dict = glucoseEvent.dictionaryRepresentation
  20. dict["timestamp"] = DateFormatter.ISO8601DateFormatter().string(from: date)
  21. return dict
  22. }
  23. }