diff --git a/Documentation/10.Upgrading_SwiftDate4.md b/Documentation/10.Upgrading_SwiftDate4.md index 41e8d3f3..27aa7486 100644 --- a/Documentation/10.Upgrading_SwiftDate4.md +++ b/Documentation/10.Upgrading_SwiftDate4.md @@ -15,7 +15,7 @@ SwiftDate 5.x is a complete rewrite of the library. While it introduces several **If you miss a features or you are interested in a new one create a new Issue.** ### Important Note about Default Region -In SwiftDate 4.x the default region is automatically set to local region, where all attributes are set automatically to the current's device's locale, timezone and calendar. +In SwiftDate 4.x the default region is automatically set to local region, where all attributes are set automatically to the current device's locale, timezone and calendar. **Since SwiftDate 5, in order to be more comply with `Date`'s default behaviour, the default region's timezone is set to GMT+0 (UTC)**. @@ -39,7 +39,7 @@ func application(_ application: UIApplication, didFinishLaunchingWithOptions lau - `Date/DateInRegion`: `isAfter()` was renamed to `isAfterDate()` - `Date/DateInRegion`: `isBefore()` was renamed to `isBeforeDate()` - `String` extension methods `date(format:fromRegion)` and `date(formats:fromRegion)` are now replaced by `toDate(_:region)` (while similar shortcuts methods are added to parse common formats: `toISODate()`, `toDotNETDate()`, `toRSSDate()` and `toSQLDate()`. -- Removed `Int` extension `second,minute,hour,day,week,month,year` due to inconsistence (use plurar versions `seconds,minutes` etc. +- Removed `Int` extension `second,minute,hour,day,week,month,year` due to inconsistencies (use plural versions `seconds,minutes` etc. - Related dates generation is now grouped under the `dateAt()` function as enum list. Therefore `nextWeekend`, `previo - `DateInRegion`: `roundedAt()` is now replaced by `dateRoundedAt()` which now compacts paramters in a single enum. - `DateInRegion`: `startOf()` and `endOf()` are now replaced by `dateAtStartOf()` and `dateAtEndOf()`and include support for both single and multiple units. diff --git a/Documentation/12.Timer_Periods.md b/Documentation/12.Timer_Periods.md index 50dafdfd..f44ab1f1 100644 --- a/Documentation/12.Timer_Periods.md +++ b/Documentation/12.Timer_Periods.md @@ -10,7 +10,7 @@ Dates are important, but the real world is a little less discrete than that. Life is made up of spans of time, like an afternoon appointment or a weeklong vacation. In DateTools, time periods are represented by the TimePeriod class and come with a suite of initializaiton, manipulation, and comparison methods to make working with them a breeze. -Time peroids consist of an Date start date and end date. +Time periods consist of a Date start date and end date. ```swift let toDate = DateInRegion().dateAtStartOf(.day) // now at 00:00 @@ -90,7 +90,7 @@ You can also check for the official relationship (like those shown in the chart) let relationship = periodA.relation(to: periodB) ``` -This function return the right value from `TimePeriodRelation` enum. +This function returns the right value from `TimePeriodRelation` enum. ## Time Period Groups @@ -122,7 +122,7 @@ collection.append([firstPeriod,secondPeriod]) ``` Sorting Sorting time periods in a collection is easy, just call one of the sort methods. -Sorting can take in place (by modifing the original collection) or can return a derivated collection. +Sorting can take in place (by modifying the original collection) or can return a derivated collection. You can therefore use: - `sorted(by type: SortType)`: to return a collection with sorted items @@ -146,7 +146,7 @@ For instance, if you would like to see all the time periods that intersect with Time period chains serve as a tightly coupled set of time periods. They are always organized by start and end date, and have their own characteristics like a `start` and `end` that are extrapolated from the time periods within. Time period chains do not allow overlaps within their set of time periods. -This type of group is ideal for modeling schedules like sequential meetings or appointments. +This type of group is ideal for modelling schedules like sequential meetings or appointments. ![](TimePeriodChain.png) diff --git a/Documentation/3.Manipulate_Date.md b/Documentation/3.Manipulate_Date.md index 8271b4fc..3bacae3e 100644 --- a/Documentation/3.Manipulate_Date.md +++ b/Documentation/3.Manipulate_Date.md @@ -13,7 +13,7 @@ - [3.2 - Get Interval Between Dates](3.Manipulate_Date.md#interval) - [3.3 - Convert Date's Region (Locale/TimeZone/Calendar)](3.Manipulate_Date.md#convert) - [3.4 - Rounding Date](3.Manipulate_Date.md#roundingdate) -- [3.5 - Trouncating Date](3.Manipulate_Date.md#trouncatingdate) +- [3.5 - Truncating Date](3.Manipulate_Date.md#truncatingdate) - [3.6 - Set Time in Date](3.Manipulate_Date.md#altertimedate) - [3.7 - Set DateTime Components](3.Manipulate_Date.md#altercomponents) - [3.8 - Generate Related Dates (`nextYear, nextWeeekday, startOfMonth, startOfWeek, prevMonth`...)](3.Manipulate_Date.md#relateddates) @@ -35,7 +35,7 @@ Dates can be manipulated as you need by using classic math operators and readabl ## 3.0 - Add & Subtract Time Units from Date -SwiftDate allows to use numbers to work with time components in dates. By extending the `Int` type it defines a list of time units: +SwiftDate allows you to use numbers to work with time components in dates. By extending the `Int` type it defines a list of time units: - `nanoseconds` - `seconds` @@ -156,7 +156,7 @@ let days = dateA.getInterval(toDate: dateB, component: .day) // 1 day ## 3.3 - Convert Date's Region (Locale/TimeZone/Calendar) -`DateInRegion` can be converted easily to anothe region just using `.convertTo(region:)` or `.convertTo(calendar: timezone:locale:)` functions. +`DateInRegion` can be converted easily to another region just using `.convertTo(region:)` or `.convertTo(calendar: timezone:locale:)` functions. - `convertTo(region:)` convert the receiver date to another region. Region may include a different time zone for example, or a locale. - `convertTo(calendar:timezone:locale:)` allows to convert the receiver date instance to a specific calendar/timezone/locale. All parameters are optional and only non-nil parameters alter the final region. For a nil param the current receiver's region attribute is kept. @@ -209,9 +209,9 @@ let r30min = "2015-01-24 15:07:20".toDate(format: format, region: rome).dateRoun [^ Top](#index) - + -## 3.5 - Trouncating Date +## 3.5 - Truncating Date Sometimes you may need to truncate a date by zeroing all values below certain time unit. `.dateTruncated(from:) and .dateTruncated(to:)` functions can be used for this scope. #### Truncating From @@ -265,7 +265,7 @@ let alteredDate = date.dateBySet(hour: 20, min: 13, secs: 15) // 2010-01-01 20:1 ## 3.7 - Set DateTime Components -SwiftDate allows you to return new date representing the date calculated by setting a specific components of a given date to given values, while trying to keep lower components the same (altering more components at the same time may result in different-than-expected results, this because lower components maybe need to be recalculated). +SwiftDate allows you to return a new date representing the date calculated by setting specific components of a given date to given values, while trying to keep lower components the same (altering more components at the same time may result in different-than-expected results, this is because lower components maybe need to be recalculated). `dateBySet(_ components: [Calendar.Component: Int]) -> DateInRegion?` @@ -292,7 +292,7 @@ SwiftDate includes 20+ different "interesting" dates you can obtain by calling ` `func dateAt(_ type: DateRelatedType) -> DateInRegion` -takes just an argument which define the type of date you want to obtain starting from the receiver date. +takes just an argument which defines the type of date you want to obtain starting from the receiver date. `DateRelatedType` is an enum which has the following options: - `startOfDay` diff --git a/Documentation/4.Compare_Dates.md b/Documentation/4.Compare_Dates.md index e6571190..da852ba8 100644 --- a/Documentation/4.Compare_Dates.md +++ b/Documentation/4.Compare_Dates.md @@ -7,7 +7,7 @@ - [**Next Chapter**: Date Formatting](#5.Date_Formatting.md) ## Compare Dates -Date comparison is available both via simple math operators (`<,>,<=,>=`) or throught several other functions which allows a more fined control of the comparison. +Date comparison is available both via simple math operators (`<,>,<=,>=`) or throught several other functions which allows a more fined grained control of the comparison. - [4.0 - Compare Dates](4.Compare_Dates.md#standard) - [4.1 - Extended Comparison with Presets (`isToday, isTomorrow, isSameWeek, isNextYear` etc.)](4.Compare_Dates.md#extended) @@ -102,7 +102,7 @@ let _ = DateInRegion().dateAt(.startOfWeek) - 1.days).compare(.isLastWeek) ## 4.2 - Comparison with Granularity -A more fined control for dates comparison can be obtained using the `.compare(toDate:granularity:)` function which offer to returns a `ComparisonResult` value that indicates the ordering of two given dates based on their components down to a given unit granularity. +A more fined grained control for dates comparison can be obtained using the `.compare(toDate:granularity:)` function which offers to return a `ComparisonResult` value that indicates the ordering of two given dates based on their components down to a given unit granularity. `func compare(toDate refDate: DateInRegion, granularity: Calendar.Component) -> ComparisonResult` @@ -122,7 +122,7 @@ Example: ## 4.3 - Check if Date is Close to Another -Decides whether a Date is "close by" another one passed in parameter, where "Being close" is measured using a precision argument which is initialized a 300 seconds (5 minutes) or a specified interval. +Decides whether a Date is "close by" another one passed in parameter, where "Being close" is measured using a precision argument which is initialized with a 300 second interval (5 minute) or a specified interval. The function is called `.compareCloseTo(_:precision:)` and takes two arguments: diff --git a/Documentation/5.Date_Formatting.md b/Documentation/5.Date_Formatting.md index 2c75e10c..8275eaa3 100644 --- a/Documentation/5.Date_Formatting.md +++ b/Documentation/5.Date_Formatting.md @@ -7,7 +7,7 @@ - [**Next Chapter**: Time Interval Formatting](#6.TimeInterval_Formatting.md) ## Date Formatting -Formatting dates and trasform to string representation is really easy with SwiftDate. All the major formats are supported and are really easy to configure. +Formatting dates and transforms to string representation is really easy with SwiftDate. All the major formats are supported and are really easy to configure. - [5.0 - Format Custom Style](5.Date_Formatting.md#customformatted) - [5.1 - ISO8601 Formatted String](5.Date_Formatting.md#isoformatted) @@ -15,6 +15,7 @@ Formatting dates and trasform to string representation is really easy with Swift - [5.3 - RSS/AltRSS Formatted String](5.Date_Formatting.md#rss) - [5.4 - SQL Formatted String](5.Date_Formatting.md#sql) - [5.5 - Relative/Colloquial Formatted String](5.Date_Formatting.md#colloquial) +- [5.6 - Mixed Date/Time Style](5.Date_Formatting.md#mixeddatetime) @@ -34,7 +35,7 @@ Example: let rome = Region(calendar: Calendars.gregorian, zone: Zones.europeRome, locale: Locales.italian) let date = DateInRegion(year: 2015, month: 1, day: 15, hour: 20, minute: 00, second: 5, nanosecond: 0, region: rome) -// Even if date's locale is set to `italin` we can still +// Even if date's locale is set to `italian` we can still // print in a different language by passing a non nil locale // to the function. let formattedString = date.toFormat("MMM dd yyyy", locale: Locales.english) // "Jan 15 2015" @@ -44,7 +45,7 @@ let formattedString = date.toFormat("MMM dd yyyy", locale: Locales.english) // " ## 5.1 - ISO8601 Formatted String -SwiftDate allows to print date instances using a configurable ISO8601 formatter which is also compatible with older version of iOS where the Apple's own class is not available. +SwiftDate allows you to print date instances using a configurable ISO8601 formatter which is also compatible with older versions of iOS where Apple's own class is not available. To use the ISO formatter call `.toISO()` function @@ -124,7 +125,7 @@ let altRSSString = date.toRSS(alt: true) // "20 Jun 2017 14:49:19 +0200" ## 5.4 - SQL Formatted String -To print SQL formatted string from a date instance you need to use the `.toSQL()` function. +To print a SQL formatted string from a date instance you need to use the `.toSQL()` function. `func toSQL() -> String` @@ -140,7 +141,7 @@ let sqlString = date.toSQL() // "2015-11-19T22:20:40.000+01" ## 5.5 - Relative/Colloquial Formatted String -Colloquial format allows you to produce human friendly string as result of the difference between a date and a a reference date (typically now). +Colloquial format allows you to produce a human friendly string as result of the difference between a date and a a reference date (typically now). Examples of colloquial formatted strings are `3 mins ago`, `2 days ago` or `just now`. SwiftDate supports over 140+ languages to produce colloquial formatted strings; the entire engine behind the library is fully customizable so, if you need, you can override default strings and produce your own variants. @@ -173,4 +174,17 @@ See the guide ["Customize Colloquial Formatter"](Customize_ColloquialFormatter.m [^ Top](#index) + + +## 5.6 - Mixed Date/Time Style + +If you to format date with different date/time styles you can use the `. dateTimeMixed` formatter option where you can choose a format both for date and time (`DateFormatter.Style`). + +```swify +// Just print full date with no time +let formatted = date.toString(.dateTimeMixed(dateStyle: .full, timeStyle: .none)) +``` + +[^ Top](#index) + [**Next Chapter**: Time Interval Formatting](#6.TimeInterval_Formatting.md) diff --git a/Documentation/6.TimeInterval_Formatting.md b/Documentation/6.TimeInterval_Formatting.md index 1934849d..e6f60227 100644 --- a/Documentation/6.TimeInterval_Formatting.md +++ b/Documentation/6.TimeInterval_Formatting.md @@ -16,7 +16,7 @@ The following methods are part of the `TimeInterval` extension provided by Swift ## 6.0 - Format Interval as String -Formatting a time interval as string is pretty simple, you just need to call the `.toString()` function of the `TimeInterval`. +Formatting a time interval as a string is pretty simple, you just need to call the `.toString()` function of the `TimeInterval`. It allows you to pick the right formatting options to represent the interval as a valid string. `func toString(options callback: ((inout ComponentsFormatterOptions) -> Void)? = nil) -> String` diff --git a/Documentation/Index.md b/Documentation/Index.md index 9639bec8..38c98977 100644 --- a/Documentation/Index.md +++ b/Documentation/Index.md @@ -3,9 +3,9 @@ ## Documentation - Reference Version: **6.1.0** -- Last Update: **Sept 2019** +- Last Update: **Sept 2020 -The following documentation explore all the major features of the library. If you are interested in a detailed, method by method documentation you can refeer to the Jazzy documentation generated by CocoaPods (you can also install in Dash). +The following documentation explores all the major features of the library. If you are interested in a detailed, method by method documentation you can refeer to the Jazzy documentation generated by CocoaPods (you can also install in Dash). ### Table Of Contents @@ -74,6 +74,7 @@ The following documentation explore all the major features of the library. If yo - [5.3 - RSS/AltRSS Formatted String](5.Date_Formatting.md#rss) - [5.4 - SQL Formatted String](5.Date_Formatting.md#sql) - [5.5 - Relative/Colloquial Formatted String](5.Date_Formatting.md#colloquial) +- [5.6 - Mixed Date/Time Style](5.Date_Formatting.md#mixeddatetime) ### [6 - Time Intervals Formatting](6.TimeInterval_Formatting.md) diff --git a/Documentation/SwiftDateArt.png b/Documentation/SwiftDateArt.png deleted file mode 100644 index a2aeb91a..00000000 Binary files a/Documentation/SwiftDateArt.png and /dev/null differ diff --git a/Documentation/SwiftDateLogo.sketch b/Documentation/SwiftDateLogo.sketch deleted file mode 100644 index 1a26e54e..00000000 Binary files a/Documentation/SwiftDateLogo.sketch and /dev/null differ diff --git a/Package.swift b/Package.swift index 811e767c..b97ec38e 100644 --- a/Package.swift +++ b/Package.swift @@ -4,12 +4,13 @@ import PackageDescription let package = Package( name: "SwiftDate", platforms: [ - .macOS(.v10_10), .iOS(.v8), .watchOS(.v2), .tvOS(.v9) + .macOS(.v10_10), .iOS(.v9), .watchOS(.v2), .tvOS(.v9) ], products: [ - .library( - name: "SwiftDate", - targets: ["SwiftDate"]) + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library(name: "SwiftDate", targets: ["SwiftDate"]), + .library(name: "SwiftDateStatic", type: .static, targets: ["SwiftDate"]), + .library(name: "SwiftDateDynamic", type: .dynamic, targets: ["SwiftDate"]) ], dependencies: [], targets: [ diff --git a/README.md b/README.md index e984d6db..3e183f50 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,12 @@
- +
-![](https://img.shields.io/cocoapods/v/SwiftDate.svg) -![](https://img.shields.io/cocoapods/p/SwiftDate.svg) -![](https://img.shields.io/badge/coverage-90%25-green.svg) -![](https://img.shields.io/badge/carthage-compatible-brightgreen.svg) -[](https://img.shields.io/travis/malcommac/SwiftDate.svg) -[![Build Status](https://travis-ci.org/malcommac/SwiftDate.svg?branch=master)](https://travis-ci.org/malcommac/SwiftDate) +## What's This? -★★ Star me to follow the project! ★★
-Created and maintained by Daniele Margutti - www.danielemargutti.com
-