Date Formatter Pool - is a small utility that creates and stores your Date Formatter for simpler reuse

Overview

Date Formatter Pool

Date Formatter Pool - is a small utility that creates and stores your Date Formatter for simpler reuse

Installation

is available in the Swift Package Manager.

Swift Package Manager

https://github.com/bartleby/DateFormatterPool.git

Basic Usage

First, add a your format to a Pool, through the expansion of DateFormat

extension DateFormat {
    static let shortDateAndTime = DateFormat(value: "MMM d, E 'at' HH:mm")
    static let shortDay = DateFormat(value: "d")
    static let shortMonth = DateFormat(value: "MMM")
    static let monthAndYear = DateFormat(value: "LLLL YYYY")
    static let shortWeekName = DateFormat(value: "EE")
}

On this site you can create the format you need: nsdateformatter.com

Then get an DateFormatter from the pool using PropertyWrapper.

struct ContentView: View {
    @DateFormatterPool(.shortDateAndTime) var shortDateAndTimeFormatter
    
    var body: some View {
        VStack {
            Text(shortDateAndTimeFormatter.string(from: Date())) // Aug 23, Tue at 12:10
        }
    }
}

or in ViewModel

final class ViewModel {
    @Published var dateString: String
    
    @DateFormatterPool(.shortDateAndTime) var shortDateAndTimeFormatter
    
    //...
    
    func configure() {
        dateString = shortDateAndTimeFormatter.string(from: Date())) // Aug 23, Tue at 12:10
    }
}

Example Apps

Coming soon

License

MIT license. See the LICENSE file for details.

You might also like...
Datify 🕛 Easypeasy date functions.

Datify 🕛 Easypeasy date functions.

Intuitive date handling in Swift

Timepiece Intuitive date handling in Swift Features 💡 Intuitive: Timepiece provides a set of helpers to make date handling easier. 🕘 Correct: Using

Elegant NTP date library in Swift
Elegant NTP date library in Swift

Kronos is an NTP client library written in Swift. It supports sub-seconds precision and provides a stable monotonic clock that won't be affected by ch

Building a better date/time library for Swift

Time Time is a Swift package that makes dealing with calendar values a natural and straight-forward process. Working with calendars can be extremely c

NasaApod - iOS, Swift, MVVM, Consuming NASA Astronomy Picture of the Day API for any selected date

NasaApod iOS, Swift, MVVM, Unit Tests Consuming NASA Astronomy Picture of the Da

Swifty Date & Time API inspired from Java 8 DateTime API.

AnyDate Swifty Date & Time API inspired from Java 8 DateTime API. Background I think that date & time API should be easy and accurate. Previous dates,

Create your own faces for watchOS.  Customize the watch hands, layout, colors, and images.  Edit faces on your phone and switch them on the watch.
Create your own faces for watchOS. Customize the watch hands, layout, colors, and images. Edit faces on your phone and switch them on the watch.

AppleWatchFaces Design your own watch faces for the apple watch. They are not real watch faces, but a watchOS app running on the watch that tells you

A TimeZonePicker UIViewController similar to the iOS Settings app. Search and select from a range of cities and countries to find your most suitable time zone.
A TimeZonePicker UIViewController similar to the iOS Settings app. Search and select from a range of cities and countries to find your most suitable time zone.

TimeZonePicker A TimeZonePicker UIViewController similar to the iOS Settings app. Search and select from a range of cities and countries to find your

Time Lines - Know when all your friends, colleagues, and family are
Time Lines - Know when all your friends, colleagues, and family are

Time Lines Know when all your friends, colleagues, and family are. Time Lines is a practical app to know when all your friends, colleagues and family

Owner
Aleksei Artemev
iOS, Mac Developer & Designer. I code and design great simple things. It is a passion of my life.
Aleksei Artemev
🎗 Super lightweight ISO8601 Date Formatter in Swift

ISO8601 ❤️ Support my apps ❤️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut mana

Khoa 19 May 12, 2020
Creates a DatePickerTextField which shows a TextField associated with a DatePicker

SwiftUI.DatePickerTextField This app creates a DatePickerTextField which shows a TextField associated with a DatePicker. When the TextField gets focus

null 3 Jun 21, 2022
A "time ago", "time since", "relative date", or "fuzzy date" category for NSDate and iOS, Objective-C, Cocoa Touch, iPhone, iPad

Migration 2014.04.12 NSDate+TimeAgo has merged with DateTools. DateTools is the parent project and Matthew York is the project head. This project is n

Kevin Lawler 1.8k Dec 2, 2022
A basic countdown app that allows the user to create, edit, and delete events. Each event contains a live countdown timer to a specified date and time.

Event Countdown App (iOS) Created by Lucas Ausberger About This Project Created: January 4, 2021 Last Updated: January 8, 2021 Current Verison: 1.1.1

Lucas Ausberger 1 Jan 8, 2022
📆 Breeze through Date, DateComponents, and TimeInterval with Swift!

Datez ?? Breeze through Date, DateComponents, and TimeInterval Highlights Two Custom Structs Only (value types FTW!): DateView: An Date associated wit

Kitz 263 Dec 7, 2022
NVDate is an extension of NSDate class (Swift4), created to make date and time manipulation easier.

NVDate is an extension of NSDate class (Swift4), created to make date and time manipulation easier. NVDate is testable and robust, we wrote intensive test to make sure everything is safe.

Noval Agung Prayogo 177 Oct 5, 2022
A customizable date picker for watchOS and SwiftUI.

Watch Date Picker A customizable date picker for watchOS and SwiftUI. Installation .package(url: "https://github.com/freyaariel/watch-date-picker.git"

Freya Ariel 30 Dec 4, 2022
Date and time manager for iOS/OSX written in Swift

Tempo was designed to work both in OSX and in iOS (7.0+). Work with the time or dates can be cumbersome, iOS development. Tempo allows you to deal easly with date and time. Basics manipulations are already implemented in Tempo.

Remi ROBERT 153 Jun 3, 2021
Swifty Date & Time API inspired from Java 8 DateTime API.

AnyDate Swifty Date & Time API inspired from Java 8 DateTime API. Background I think that date & time API should be easy and accurate. Previous dates,

Jungwon An 182 Dec 1, 2022
DateHelper - A high performant Swift Date Extension for creating, converting, comparing, or modifying dates.

DateHelper A high performant Swift Date Extension for creating, converting, comparing, or modifying dates. Capabilities Creating a Date from a String

Melvin Rivera 1.4k Jan 2, 2023