[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6756":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":17,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":23,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":33,"readmeContent":34,"aiSummary":35,"trendingCount":16,"starSnapshotCount":16,"syncStatus":36,"lastSyncTime":37,"discoverSource":38},6756,"SwiftDate","malcommac\u002FSwiftDate","malcommac","🐔 Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.","",null,"Swift",7703,774,107,74,0,1,5,65.67,"MIT License",false,"master",true,[25,26,27,28,29,30,31,32],"date","date-formatting","date-time","nsdate","nsdate-category","swift","swiftdate","timezone","2026-06-12 04:00:30","\u003Cp align=\"center\" >\n  \u003Cimg src=\"banner.png\" width=300px alt=\"SwiftDate\" title=\"SwiftDate\">\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\u003Cstrong>Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.\u003C\u002Fstrong>\u003C\u002Fp>\n\n## What's This?\n\nSwiftDate is the **definitive toolchain to manipulate and display dates and time zones** on all Apple platform and even on Linux and Swift Server Side frameworks like Vapor or Kitura.  \n**Over 3 million of downloads on [CocoaPods](https:\u002F\u002Fcocoapods.org\u002Fpods\u002FSwiftDate).**\n\nFrom simple date manipulation to complex business logic SwiftDate maybe the right choice for your next project.\n\n- [x] **Easy Date Parsing** (custom formats, iso8601, rss & many more)\n- [x] **Easy Date Formatting** even with colloquial formatter and 140+ supported languages\n- [x] **Easy math operations with time units** (`2.hours + 5.minutes`...)\n- [x] **Intuitive components extraction** (`day, hour, nearestHour, weekdayNameShort` etc.)\n- [x] **Derivated dates generation** (`nextWeek, nextMonth, nextWeekday, tomorrow`...)\n- [x] Over **20+ fine grained date comparison** functions (`isToday, isTomorrow, isSameWeek, isNextYear`...)\n- [x] Swift 4's **Codable Support**\n- [x] **Random dates** generation\n- [x] **Fine grained date enumeration** functions\n- [x] **Time period** support\n- [x] **Convert TimeIntervals** to other units (`2.hours.toUnits(.minutes)`)\n\nand of course...\n\n- **IT'S TESTED!**. As 5.x the project has 90% of code coverage (want help us? write some unit tests and make a PR)\n- **IT'S FULLY DOCUMENTED!**, [both with a complete guide](\u002FDocumentation\u002FIndex.md) and with Jazzy!\n- **WE LOVE PLAYGROUND!** [Check out](\u002FPlaygrounds\u002FSwiftDate.playground) our interactive playground!\n\n\n## Start with SwiftDate\n\nThe entire library is fully documented both via XCode method inspector and a complete markdown documentation you can found below.\n\n- → **[Full Documentation](\u002FDocumentation\u002FIndex.md)**\n- → **[Requirements, Install, License & More](\u002FDocumentation\u002F0.Informations.md)**\n- → **[Upgrading from SwiftDate 4](\u002FDocumentation\u002F10.Upgrading_SwiftDate4.md)**\n\n### Explore SwiftDate\n\nFrom simple date manipulation to complex business logic SwiftDate maybe the right choice for your next project.\n\nLet me show to you the main features of the library:\n\n- [Date Parsing](#1)\n- [Date Manipulation](#2)\n- [Date Comparsion](#3)\n- [Date Creation with Region (Timezone, Calendar & Locale)](#4)\n- [Derivated Dates](#5)\n- [Components Extraction](#6)\n- [Switch between timezones\u002Flocale and calendars](#7)\n- [Date Formatting](#8)\n- [Relative Date Formatting (fully customizable!)](#9)\n- [Codable Support](#10)\n- [Time Periods](#11)\n\n\u003Ca name=\"1\"\u002F>\n\n### 1. Date Parsing\nSwiftDate can recognize all the major datetime formats  automatically (ISO8601, RSS, Alt RSS, .NET, SQL, HTTP...) and you can also provide your own formats.\nCreating a new date has never been so easy!\n\n```swift\n\u002F\u002F All default datetime formats (15+) are recognized automatically\nlet _ = \"2010-05-20 15:30:00\".toDate()\n\u002F\u002F You can also provide your own format!\nlet _ = \"2010-05-20 15:30\".toDate(\"yyyy-MM-dd HH:mm\")\n\u002F\u002F All ISO8601 variants are supported too with timezone parsing!\nlet _ = \"2017-09-17T11:59:29+02:00\".toISODate()\n\u002F\u002F RSS, Extended, HTTP, SQL, .NET and all the major variants are supported!\nlet _ = \"19 Nov 2015 22:20:40 +0100\".toRSS(alt: true)\n\n```\n\n\u003Ca name=\"2\"\u002F>\n\n### 2. Date Manipulation\nDate can be manipulated by adding or removing time components using a natural language; time unit extraction is also easy and includes the support for timezone, calendar and locales!\n\nManipulation can be done with standard math operators and between dates, time intervals, date components and relevant time units!\n\n```swift\n\u002F\u002F Math operations support time units\nlet _ = (\"2010-05-20 15:30:00\".toDate() + 3.months - 2.days)\nlet _ = Date() + 3.hours\nlet _ = date1 + [.year:1, .month:2, .hour:5]\nlet _ = date1 + date2\n\u002F\u002F extract single time unit components from date manipulation\nlet over1Year = (date3 - date2).year > 1\n```\n\u003Ca name=\"3\"\u002F>\n\n### 3. Date Comparison\nSwiftDate include an extensive set of comparison functions; you can compare two dates by granularity, check if a date is an particular day, range and practically any other comparison you ever need.\n\nComparison is also available via standard math operators like (`>, >=, \u003C, \u003C=`).\n\n```swift\n\u002F\u002F Standard math comparison is allowed\nlet _ = dateA >= dateB || dateC \u003C dateB\n\n\u002F\u002F Complex comparisons includes granularity support\nlet _ = dateA.compare(toDate: dateB, granularity: .hour) == .orderedSame\nlet _ = dateA.isAfterDate(dateB, orEqual: true, granularity: .month) \u002F\u002F > until month granularity\nlet _ = dateC.isInRange(date: dateA, and: dateB, orEqual: true, granularity: .day) \u002F\u002F > until day granularity\nlet _ = dateA.earlierDate(dateB) \u002F\u002F earlier date\nlet _ = dateA.laterDate(dateB) \u002F\u002F later date\n\n\u002F\u002F Check if date is close to another with a given precision\nlet _ = dateA.compareCloseTo(dateB, precision: 1.hours.timeInterval\n\n\u002F\u002F Compare for relevant events:\n\u002F\u002F .isToday, .isYesterday, .isTomorrow, .isWeekend, isNextWeek\n\u002F\u002F .isSameDay, .isMorning, .isWeekday ...\nlet _ = date.compare(.isToday)\nlet _ = date.compare(.isNight)\nlet _ = date.compare(.isNextWeek)\nlet _ = date.compare(.isThisMonth)\nlet _ = date.compare(.startOfWeek)\nlet _ = date.compare(.isNextYear)\n\u002F\u002F ...and MORE THAN 30 OTHER COMPARISONS BUILT IN\n\n\u002F\u002F Operation in arrays (oldestIn, newestIn, sortedByNewest, sortedByOldest...)\nlet _ = DateInRegion.oldestIn(list: datesArray)\nlet _ = DateInRegion.sortedByNewest(list: datesArray)\n```\n\n\u003Ca name=\"4\"\u002F>\n\n### 4. Date Creation with Region (Timezone, Calendar & Locale)\nYou can create new dates from a string, time intervals or using date components. SwiftDate offers a wide set of functions to create and derivate your dates even with random generation!\n\n```swift\n\u002F\u002F All dates includes timezone, calendar and locales!\n\u002F\u002F Create from string\nlet rome = Region(calendar: Calendars.gregorian, zone: Zones.europeRome, locale: Locales.italian)\nlet date1 = DateInRegion(\"2010-01-01 00:00:00\", region: rome)!\n\n\u002F\u002F Create date from intervals\nlet _ = DateInRegion(seconds: 39940, region: rome)\nlet _ = DateInRegion(milliseconds: 5000, region: rome)\n\n\u002F\u002F Date from components\nlet _ = DateInRegion(components: {\n\t$0.year = 2001\n\t$0.month = 9\n\t$0.day = 11\n\t$0.hour = 12\n\t$0.minute = 0\n}, region: rome)\nlet _ = DateInRegion(year: 2001, month: 1, day: 5, hour: 23, minute: 30, second: 0, region: rome)\n\n\u002F\u002F Random date generation with\u002Fwithout bounds\nlet _ = DateInRegion.randomDate(region: rome)\nlet _ = DateInRegion.randomDate(withinDaysBeforeToday: 5)\nlet _ = DateInRegion.randomDates(count: 50, between: lowerLimitDate, and: upperLimitDate, region: rome)\n```\n\u003Ca name=\"5\"\u002F>\n\n### 5. Derivated Dates\nDate can be also generated starting from other dates; SwiftDate includes an extensive set of functions to generate.\nOver 20 different derivated dates can be created easily using `dateAt()` function.\n\n```swift\nlet _ = DateInRegion().dateAt(.endOfDay) \u002F\u002F today at the end of the day\n\u002F\u002F Over 20 different relevant dates including .startOfDay,\n\u002F\u002F .endOfDay, .startOfWeek, .tomorrow, .nextWeekday, .nextMonth, .prevYear, .nearestMinute and many others!\nlet _ = dateA.nextWeekday(.friday) \u002F\u002F the next friday after dateA\nlet _ = (date.dateAt(.startOfMonth) - 3.days)\nlet _ = dateA.compare(.endOfWeek)\n\n\u002F\u002F Enumerate dates in range by providing your own custom\n\u002F\u002F increment expressed in date components\nlet from = DateInRegion(\"2015-01-01 10:00:00\", region: rome)!\nlet to = DateInRegion(\"2015-01-02 03:00:00\", region: rome)!\nlet increment2 = DateComponents.create {\n\t$0.hour = 1\n\t$0.minute = 30\n\t$0.second = 10\n}\n\u002F\u002F generate dates in range by incrementing +1h,30m,10s each new date\nlet dates = DateInRegion.enumerateDates(from: fromDate2, to: toDate2, increment: increment2)\n\n\u002F\u002F Get all mondays in Jan 2019\nlet mondaysInJan2019 = Date.datesForWeekday(.monday, inMonth: 1, ofYear: 2019)\n\n\u002F\u002F Altering time components\nlet _ = dateA.dateBySet(hour: 10, min: 0, secs: 0)\n\n\u002F\u002F Truncating a date\nlet _ = dateA.dateTruncated(at: [.year,.month,.day]) \u002F\u002F reset all time components keeping only date\n\n\u002F\u002F Rounding a date\nlet _ = dateA.dateRoundedAt(.toMins(10))\nlet _ = dateA.dateRoundedAt(.toFloor30Mins)\n\n\u002F\u002F Adding components\nlet _ = dateA.dateByAdding(5,.year)\n\n\u002F\u002F Date at the start\u002Fend of any time component\nlet _ = dateA.dateAtEndOf(.year) \u002F\u002F 31 of Dec at 23:59:59\nlet _ = dateA.dateAtStartOf(.day) \u002F\u002F at 00:00:00 of the same day\nlet _ = dateA.dateAtStartOf(.month) \u002F\u002F at 00:00:00 of the first day of the month\n```\n\n\u003Ca name=\"6\"\u002F>\n\n### 6. Components Extraction\nYou can extract components directly from dates and it includes the right value expressed in date's region (the right timezone and set locale!).\n\n```swift\n\u002F\u002F Create a date in a region, London but with the lcoale set to IT\nlet london = Region(calendar: .gregorian, zone: .europeLondon, locale: .italian)\nlet date = DateInRegion(\"2018-02-05 23:14:45\", format: dateFormat, region: london)!\n\n\u002F\u002F You can extract any of the all available time units.\n\u002F\u002F VALUES ARE EXPRESSED IN THE REGION OF THE DATE (THE RIGHT TIMEZONE).\n\u002F\u002F (you can still get the UTC\u002Fabsolute value by getting the inner's absoluteDate).\n\nlet _ = date.year \u002F\u002F 2018\nlet _ = date.month \u002F\u002F 2\nlet _ = date.monthNameDefault \u002F\u002F 'Febbraio' as the locale is the to IT!\nlet _ = date.firstDayOfWeek \u002F\u002F 5\nlet _ = date.weekdayNameShort \u002F\u002F 'Lun' as locale is the to IT\n\u002F\u002F ... all components are supported: .year, .month, .day, .hour, .minute, .second,\n\u002F\u002F .monthName, .weekday, .nearestHour, .firstDayOfWeek. .quarter and so on...\n```\n\n\u003Ca name=\"7\"\u002F>\n\n### 7. Switch between timezones\u002Flocale and calendars\nYou can easily convert any date to another region (aka another calendar, locale or timezone) easily!\nNew date contains all values expressed into the destination reason\n\n```swift\n\u002F\u002F Conversion between timezones is easy using convertTo(region:) function\nlet rNY = Region(calendar: Calendars.gregorian, zone: Zones.americaNewYork, locale: Locales.english)\nlet rRome = Region(calendar: Calendars.gregorian, zone: Zones.europeRome, locale: Locales.italian)\nlet dateInNY = \"2017-01-01 00:00:00\".toDate(region: rNY)\nlet dateInRome = dateInNY?.convertTo(region: rRome)!\nprint(dateInRome.toString()) \u002F\u002F \"dom gen 01 06:00:00 +0100 2017\\n\"\n\n\u002F\u002F You can also convert single region's attributes\nlet dateInIndia = dateInNY?.convertTo(timezone: Zones.indianChristmas, locale: Locales.nepaliIndia)\nprint(\"\\(dateInIndia!.toString())\") \u002F\u002F \"आइत जनवरी ०१ १२:००:०० +0700 २०१७\\n\"\n```\n\n\u003Ca name=\"8\"\u002F>\n\n### 8. Date Formatting\nDate formatting is easy, you can specify your own format, locale or use any of the provided ones.\n\n```swift\n\u002F\u002F Date Formatting\nlet london = Region(calendar: .gregorian, zone: .europeLondon, locale: .english)\nlet date = ... \u002F\u002F 2017-07-22T18:27:02+02:00 in london region\nlet _ = date.toDotNET() \u002F\u002F \u002FDate(1500740822000+0200)\u002F\nlet _ = date.toISODate() \u002F\u002F 2017-07-22T18:27:02+02:00\nlet _ = date.toFormat(\"dd MMM yyyy 'at' HH:mm\") \u002F\u002F \"22 July 2017 at 18:27\"\n\n\u002F\u002F You can also easily change locale when formatting a region\nlet _ = date.toFormat(\"dd MMM\", locale: .italian) \u002F\u002F \"22 Luglio\"\n\n\u002F\u002F Time Interval Formatting as Countdown\nlet interval: TimeInterval = (2.hours.timeInterval) + (34.minutes.timeInterval) + (5.seconds.timeInterval)\nlet _ = interval.toClock() \u002F\u002F \"2:34:05\"\n\n\u002F\u002F Time Interval Formatting by Components\nlet _ = interval.toString {\n\t$0.maximumUnitCount = 4\n\t$0.allowedUnits = [.day, .hour, .minute]\n\t$0.collapsesLargestUnit = true\n\t$0.unitsStyle = .abbreviated\n} \u002F\u002F \"2h 34m\"\n```\n\n\u003Ca name=\"9\"\u002F>\n\n### 9. Relative Date Formatting (fully customizable!)\nRelative formatting is all new in SwiftDate; it supports 120+ languages with two different styles (`.default, .twitter`), 9 flavours (`.long, .longTime, .longConvenient, .short, .shortTime, .shortConvenient, .narrow, .tiny, .quantify`) and all of them are customizable as you need.\nThe extensible format allows you to provide your own translations and rules to override the default behaviour.\n\n```swift\n\u002F\u002F Twitter Style\nlet _ = (Date() - 3.minutes).toRelative(style: RelativeFormatter.twitterStyle(), locale: Locales.english) \u002F\u002F \"3m\"\nlet _ = (Date() - 6.minutes).toRelative(style: RelativeFormatter.twitterStyle(), locale: Locales.italian) \u002F\u002F \"6 min fa\"\n\n\u002F\u002F Default Style\nlet _ = (now2 - 5.hours).toRelative(style: RelativeFormatter.defaultStyle(), locale: Locales.english) \u002F\u002F \"5 hours ago\"\nlet y = (now2 - 40.minutes).toRelative(style: RelativeFormatter.defaultStyle(), locale: Locales.italian) \u002F\u002F \"45 minuti fa\"\n```\n\u003Ca name=\"10\"\u002F>\n\n### 10. Codable Support\nBoth `DateInRegion` and `Region` fully support the new Swift's `Codable` protocol. This mean you can safely encode\u002Fdecode them:\n\n```swift\n\u002F\u002F Encoding\u002FDecoding a Region\nlet region = Region(calendar: Calendars.gregorian, zone: Zones.europeOslo, locale: Locales.english)\nlet encodedJSON = try JSONEncoder().encode(region)\nlet decodedRegion = try JSONDecoder().decode(Region.self, from: encodedJSON)\n\n\u002F\u002F Encoding\u002FDecoding a DateInRegion\nlet date = DateInRegion(\"2015-09-24T13:20:55\", region: region)\nlet encodedDate = try JSONEncoder().encode(date)\nlet decodedDate = try JSONDecoder().decode(DateInRegion.self, from: encodedDate)\n```\n\n\u003Ca name=\"11\"\u002F>\n\n### 11. Time Periods\nSwiftDate integrates the great Matthew York's [DateTools](https:\u002F\u002Fgithub.com\u002FMatthewYork\u002FDateTools) module in order to support Time Periods.\n\nSee [Time Periods](\u002FDocumentation\u002F12.Timer_Periods.md) section of the documentation.\n","SwiftDate 是一个用于解析、验证、操作、比较和显示日期时间及时区的 Swift 工具包。它支持自定义格式、ISO8601 等多种日期格式的轻松解析与格式化，提供了直观的时间单位运算、日期组件提取、衍生日期生成以及超过 20 种精细的日期比较函数等功能。此外，SwiftDate 还支持 Swift 4 的 Codable 特性，并且具备良好的测试覆盖率和全面的文档支持。该工具适用于需要处理复杂日期逻辑的各种 Apple 平台应用开发场景，包括 iOS、macOS、watchOS 和 tvOS，同时也兼容 Linux 和 Swift 服务器端框架如 Vapor 或 Kitura。",2,"2026-06-11 03:08:42","top_language"]