Backport of iOS 15 formatting api

Overview

BPFormatted

This is a back-port of the .formatted API in Foundation that was introduced at WWDC '21 for iOS 15, macOS 12.0, tvOS 15.0, and watchOS 8.0.

Most developers cannot start developing their apps from those platforms and upwards.

But now they can! This package provides the same nice api for projects starting at iOS 9.0, macOS 10.10, tvOS 9.0 and watchOS 2.0!!!

Goal

To provide the exact same api with the exact same results as Apple's Foundation api.

Features

What's already available and what's to come.

  • Date
  • ISO8601 (iOS 10, macOS 10.12, watchOS 3, tvOS 10)
  • DateInterval
  • Relative Dates (iOS 15, macOS 10.15, watchOS 6, tvOS 13)
  • List
  • Measurement
  • PersonNameComponent
  • RelativeDate
  • ByteCount
  • String parsing (maybe)

How to use

The same API as in Apple's Foundation framework, but prefixed with bp.

// Apple's Foundation
Date().formatted()
Date().formatted(.dateTime.month().year(.twoDigits))
(Date()..<Date()).formatted(.interval.year())
// BPFormatted
Date().bpFormatted()
Date().bpFormatted(.dateTime.month().year(.twoDigits))
(Date()..<Date()).bpFormatted(.interval.year())

You will get automatic compiler warnings if you try to use this framework when your minimum deployment already allows you to use Apple's official API.

All possibilities are not yet fully documented by Apple. Your best bet right now is to watch What's new in Foundation (WWDC 2021) starting at 14:30.

Warning

  • Since the current release of Foundation this is based on is still in bèta, everything is still subject to change.
  • To use the same syntax as the new API, you need to use Swift 5.5, otherwise, a longer form will be necessary.
// Swift 5.5
Date().bpFormatted(.dateTime)
// Swift 5.x
Date().bpFormatted(Date.BPFormatStyle.dateTime)
  • This is my first open source project. If you have any suggestions/improvements, I am open-minded.

Installation

SPM:

dependencies: [
    .package(url: "https://github.com/simonsalomons/BPFormatted.git", .upToNextMajor(from: "0.0.1"))
]

CocoaPods:

TBA

You might also like...
The swiftest way to build iOS apps that connect to Salesforce
The swiftest way to build iOS apps that connect to Salesforce

Build iOS apps fast on the Salesforce Platform with Swiftly Salesforce: Written entirely in Swift. Uses Swift's Combine framework to simplify complex,

CovidCertificate SDK for iOS

This is the Swiss implementation of the Electronic Health Certificates (EHN) Specification [1] used to verify the validity of Digital Covid Certificates. It is partly based on the reference implementation of EHN's ValidationCore

App iOS correspondiente al proyecto twitimer.com de la comunidad MoureDev
App iOS correspondiente al proyecto twitimer.com de la comunidad MoureDev

⏳ Twitimer iOS Twitimer es una App gratuita para iOS y Android que se ha desarrollado para ayudar a usuarios de Twitch, pero sobre todo pensando en ge

Desk360 Mobile Chat SDK for iOS

Desk360 Chat iOS SDK Desk360 Chat SDK provides simplicity and usability in one place. With this feature, you can provide live support to your customer

WANNA SDK enhances your iOS app with virtual try-on capabilities for shoes and watches

WANNA SDK enhances your iOS app with virtual try-on capabilities for shoes and watches. With this feature, your users will be able to see in real time how the selected product looks on them, just by pointing their smartphone camera at their feet or wrist.

Backport of SwiftUI.AsyncImage to iOS 14, macOS 11, tvOS 14 and watchOS 7 and earlier.

SBPAsyncImage Backport of SwiftUI.AsyncImage to iOS 14, macOS 11, tvOS 14 and watchOS 7 and earlier. AsyncImage is a view that asynchronously loads an

A backport of UIHostingConfiguration for iOS 14.0+

UIHostingConfigurationBackport A backport of UIHostingConfiguration for iOS 14.0+. import UIHostingConfigurationBackport cell.contentConfiguration =

A library for formatting strings on iOS and macOS

Sprinter Introduction What? Why? How? Usage Installation Integration Localization Thread Safety Advanced Usage Introduction What? Sprinter is a librar

A tool for Swift code modification intermediating between code generation and formatting.

swift-mod A tool for Swift code modification intermediating between code generation and formatting. Overview swift-mod is a tool for Swift code modifi

A command-line tool and Xcode Extension for formatting Swift code
A command-line tool and Xcode Extension for formatting Swift code

Table of Contents What? Why? How? Command-line tool Xcode source editor extension Xcode build phase Via Applescript VSCode plugin Sublime Text plugin

A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.

PhoneNumberKit Swift 5.3 framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. Features F

A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.

PhoneNumberKit Swift 5.3 framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. Features F

XShared - Xcode extension that allows you copying the code with special formatting quotes for social (Slack, Telegram)
XShared - Xcode extension that allows you copying the code with special formatting quotes for social (Slack, Telegram)

This extension is for those who like to show code to the public 😎 Xcode extension which allows you copying the code with special formatting quotes fo

A lightweight Swift date library for parsing, validating, manipulating, and formatting dates based on moment.js.

A lightweight Swift date library for parsing, validating, manipulating, and formatting dates based on moment.js.

An original project making use of custom UITableViewCells, date formatting, json parsing, and handling user location.

SunTimes An original project making use of custom UITableViewCells, date formatting, json parsing, date and time formatting based on the json data, an

An open source package for as-you-type formatting in SwiftUI.
An open source package for as-you-type formatting in SwiftUI.

DiffableTextViews An open source package for as-you-type formatting in SwiftUI. Features Feature Description ⌨️ Responsive Formats text as you type 🪄

DevTool - A simple UI and powerful Mac OS application, Such as JSON-Formatting tool, JSON-to-model tool, AppIcon generator, Network-Request tool...
DevTool - A simple UI and powerful Mac OS application, Such as JSON-Formatting tool, JSON-to-model tool, AppIcon generator, Network-Request tool...

🔥 🔥 🔥 A simple UI and powerful Mac OS application. It is a collection of tools commonly used in my development work. Such as JSON-Formatting tool, JSON-to-model tool, AppIcon generator, Network-Request tool...

Search jailbreak packages using the Tweakio API, Parcility API or Canister API straight from Cydia, Installer, Sileo and Zebra!

Tweakio Search packages globally directly from your favourite package manager! Works with Cydia, Installer, Zebra and Sileo! How does it work The twea

Github iOS Client  based on Github REST V3 API and GraphQL V4 API
Github iOS Client based on Github REST V3 API and GraphQL V4 API

ZLGithubClient Github iOS 客户端 by Existorlive Objective-c 2.0 Swift 5 Cocoapods 1.9.1 iOS = 11.0 基于 Github REST V3 API 和 Github GraphQL V4 API 开发的iOS客

Releases(0.0.5)
Owner
Simon Salomons
Simon Salomons
Google Directions API helper for iOS, written in Swift

PXGoogleDirections Google Directions API SDK for iOS, entirely written in Swift. ?? Features Supports all features from the Google Directions API as o

Romain L 268 Aug 18, 2022
Unofficial iOS/macOS SDK for the Notion API.

NotionClient: a Notion SDK for iOS & macOS Unofficial Notion API SDK for iOS & macOS. This is an alpha version and still work in progress. TODO Featur

David De Bels 15 Aug 4, 2022
Swift implementation of Github REST API v3

GitHubAPI Swift implementation of GitHub REST api v3. Library support Swift 4.2. Work is in progress. Currently supported: Issues API. Activity API(Fe

Serhii Londar 77 Jan 7, 2023
Swift Reddit API Wrapper

reddift reddift is Swift Reddit API Wrapper framework, and includes a browser is developed using the framework. Supports OAuth2(is not supported on tv

sonson 236 Dec 28, 2022
Instagram API client written in Swift

SwiftInstagram is a wrapper for the Instagram API written in Swift. It allows you to authenticate users and request data from Instagram effortlessly.

Ander Goig 580 Nov 25, 2022
Instagram Private API Swift

SwiftyInsta Please notice SwiftyInsta may not be actively maintained at the moment of you reading this note. Refer to #244 for more info. Instagram of

Mahdi Makhdumi 218 Jan 5, 2023
A Swift client for the OpenAI API.

OpenAI A Swift client for the OpenAI API. Requirements Swift 5.3+ An OpenAI API Key Example Usage Completions import OpenAI

Mattt 161 Dec 26, 2022
Swift Bot with Vapor for Telegram Bot Api

Telegram Vapor Bot Please support Swift Telegram Vapor Bot Lib development by giving a ⭐️ Telegram Bot based on Swift Vapor. Swift Server Side Communi

OleG. 104 Jan 6, 2023
Swift library for the Twitter API v1 and v2

Swift library for the Twitter API v1 and v2

mironal 96 Dec 30, 2022
Swifter - A Twitter framework for iOS & OS X written in Swift

Getting Started Installation If you're using Xcode 6 and above, Swifter can be installed by simply dragging the Swifter Xcode project into your own pr

Matt Donnelly 2.4k Dec 26, 2022