Giter Site home page Giter Site logo

time-independent-date-swift's Introduction

Time Independent Dates in Swift

This library offers TimeIndependentDate, a type representing a date independent of a particular time. It therefore represents approximately 48 hours of real time on Earth.

Most often, it is important that a date also near-precisely represent a point in time. For that, we have Foundation.Date. TimeIndependentDate fills a gap where, in limited circumstances, we need to deal with a date independent of time. This is particularly useful when interfacing with third party systems which supply dates independent of time.

Example Usage

// Initialise a date, throwing a `TimeIndependentDate` error if the supplied
// literal values are invalid.
let timeIndependentDate = try TimeIndependentDate(
    year: 2020,
    month: .january,
    day: 1
)

// Parse a date from a string. Adjust encoding order as desired. A
// `TimeIndependentDateError` is thrown if the supplied string
// is not a valid date.
let timeIndependentDate = try TimeIndependentDate.from(
    "2021-01-01",
    encodingOrder: .dayFirst
)

Documentation

Select Product > Build Documentation in Xcode to build the library doccarchive. Or, download the latest documentation: TimeIndependentDates.doccarchive.zip for v1.01

Versioning

TimeIndependentDates obeys Semantic Versioning 2.0.0 specifications.

Installation

Add TimeIndependentDates as a dependency in your Package.swift file. Here is a simple example:

let package = Package(
    name: "YourLibrary",
    products: [
        .library(
            name: "YourLibrary",
            targets: ["YourLibrary"]),
    ],
    dependencies: [
        .package(url: "https://github.com/hwjeremy/time-independent-date-swift", from: "1.0.0")
    ],
    targets: [
        .target(
            name: "YourLibrary",
            dependencies: [
                .product(name: "TimeIndependentDates", package: "time-independent-date-swift")
            ]
        )
    ]
)

Contact

Comments, pull requests, and issues are welcome on GitHub

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.