WebcomDate

public struct WebcomDate : Codable, Hashable, Comparable

A value representing a date and time, which can be computed by the Datasync back-end.

A WebcomDate wraps a classic Date. The value property allows to retrieve the wrapped value. It has also a special instance, WebcomDate.backEndCurrentDate, which represents the back-end current date and time.

To store the current date in the Datasync database, it is better to use WebcomDate.backEndCurrentDate rather than Date() since the former allows to take into account the offset between the device time and the back-end time seamlessly. To retrieve the device local date corresponding to a WebcomDate read in the Datasync database, use the DatasyncState.ConnectionState.deviceDate(for:) method, as it will also take the offset into account.

WebcomDate obviously conforms to Codable, Hashable, Equatable and Comparable protocols, so it can be used everywhere Date would be used.

Constants

  • A special value that represents the back-end current date and time.

    This value is processed on the back-end side when writing this value into the database. It is designed to take into account the time offset between the client and the back-end.

    Declaration

    Swift

    public static let backEndCurrentDate: WebcomDate

Initializers

  • Creates a new instance.

    Declaration

    Swift

    public init(_ date: Date)

    Parameters

    date

    The date and time represented by this instance.

  • Declaration

    Swift

    public init(from decoder: Decoder) throws

Encodable Protocol

  • Declaration

    Swift

    public func encode(to encoder: Encoder) throws

Comparable Protocol

  • Declaration

    Swift

    public static func < (left: WebcomDate, right: WebcomDate) -> Bool

API

  • The date and time represented by this instance.

    When this instance is .backEndCurrentDate, the returned value is a non-specified valid date and time.

    Declaration

    Swift

    public var value: Date { get }