All Projects → leonx98 → Swift-ISO8601-DurationParser

leonx98 / Swift-ISO8601-DurationParser

Licence: MIT license
Swift ISO8601 Parser

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swift-ISO8601-DurationParser

edtf.js
Extended Date Time Format (ISO 8601-2 / EDTF) Parser for JavaScript
Stars: ✭ 44 (+83.33%)
Mutual labels:  time, iso8601
Time.dart
⏰ Type-safe DateTime and Duration calculations, powered by extensions.
Stars: ✭ 363 (+1412.5%)
Mutual labels:  duration, time
duration
Parse iso8601 duration strings, and use to shift dates/times.
Stars: ✭ 51 (+112.5%)
Mutual labels:  time, iso8601
Durafmt
🕗 Better time duration formatting in Go!
Stars: ✭ 362 (+1408.33%)
Mutual labels:  duration, time
Humanizeduration.js
361000 becomes "6 minutes, 1 second"
Stars: ✭ 1,234 (+5041.67%)
Mutual labels:  duration, time
As Duration
Extraction of ActiveSupport::Duration from Rails
Stars: ✭ 126 (+425%)
Mutual labels:  duration, time
duration-humanizer
361000 becomes "6 minutes, 1 second"
Stars: ✭ 61 (+154.17%)
Mutual labels:  duration, time
Time
Windows tool for measuring command/program execution speed
Stars: ✭ 21 (-12.5%)
Mutual labels:  duration, time
HorizontalTimesLayout
Layout to display time slots in horizontal 24 hour format
Stars: ✭ 31 (+29.17%)
Mutual labels:  time, iphone
Ruby Duration
Immutable type that represents some amount of time with accuracy in seconds.
Stars: ✭ 122 (+408.33%)
Mutual labels:  duration, time
iso8601
A fast ISO8601 date parser for Go
Stars: ✭ 122 (+408.33%)
Mutual labels:  time, iso8601
minitime
Minitime - a Java Time wrapper for Scala and Scala.js
Stars: ✭ 16 (-33.33%)
Mutual labels:  time
ForceSketch
Demonstration of a Sketching App Using 3D Touch
Stars: ✭ 18 (-25%)
Mutual labels:  iphone
timechange
Efficient Updating of Date-Times
Stars: ✭ 25 (+4.17%)
Mutual labels:  time
AppLibraryController
App Library Controller - Control App Library
Stars: ✭ 14 (-41.67%)
Mutual labels:  iphone
ZudVPN
A mobile application to deploy private VPN servers in the cloud with DNS ad-blocking and other features
Stars: ✭ 119 (+395.83%)
Mutual labels:  iphone
Manual-del-guerrero-movil-Phonegap
Ejemplos de código PhoneGap
Stars: ✭ 14 (-41.67%)
Mutual labels:  iphone
ngx-mat-timepicker
A true material timepicker
Stars: ✭ 45 (+87.5%)
Mutual labels:  time
lit-date
Light-weight, faster datetime formatter for modern browsers.
Stars: ✭ 33 (+37.5%)
Mutual labels:  time
easyappointments-integrations
📅 Various platform integration packages of Easy!Appointments
Stars: ✭ 29 (+20.83%)
Mutual labels:  time

Swift/ISO8601-Duration Parser

Swift 5 extension which converts ISO 8601 duration strings into a DateComponents object.

Examples

PT12H = 12 hours
P3D = 3 days
P3DT12H = 3 days, 12 hours
P3Y6M4DT12H30M5S = 3 years, 6 months, 4 days, 12 hours, 30 minutes and 5 seconds
P10W = 70 days
For more information look here: https://en.wikipedia.org/wiki/ISO_8601#Durations

Usage

let durationString = "P3Y6M4DT12H30M5S"
let components = DateComponents.durationFrom8601String(durationString)
components?.year // 3
components?.month // 6
components?.day // 4
components?.hour // 12
components?.minute // 30
components?.second // 5

let durationStringInWeeks = "P8W"
let componentsForWeeks = DateComponents.durationFrom8601String(durationStringInWeeks)
componentsForWeeks?.day //56

Installation

SPM

You can use SPM. Add the following to your Package.swift.

.package(url: "https://github.com/leonx98/Swift-ISO8601-DurationParser.git", .upToNextMajor(from: "0.9.0")),

Donation

If you like my open source libraries, you can sponsor it! ☺️

paypal

License

Swift/ISO8601-Duration Parser is available under the MIT license. See the LICENSE file for more info.

Acknowledgments

Objective-C version from @kevinrandrup

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].