You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Returns a date offset by the specified time interval from this date to the past.
5
25
/// This method is useful when you need to calculate a date that occurred a certain duration before the current date instance.
6
26
/// For example, if you want to find out what the date was 2 hours ago from a given date, you can use this method by passing the time interval for 2 hours in seconds.
Copy file name to clipboardExpand all lines: Sources/HandySwift/HandySwift.docc/Essentials/New Types.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -47,11 +47,11 @@ let todayNextWeek = GregorianDay.today.advanced(by: 7)
47
47
48
48
> Note: `GregorianDay` conforms to all the protocols you would expect, such as `Codable`, `Hashable`, and `Comparable`. For encoding/decoding, it uses the ISO format as in "2014-07-13".
49
49
50
-
``GregorianTimeOfDay`` is the counterpart:
50
+
``GregorianTime`` is the counterpart:
51
51
52
52
```swift
53
-
let iPhoneAnnounceTime =GregorianTimeOfDay(hour: 09, minute: 41)
54
-
let anHourFromNow =GregorianTimeOfDay.now.advanced(by: .hours(1))
53
+
let iPhoneAnnounceTime =GregorianTime(hour: 09, minute: 41)
54
+
let anHourFromNow =GregorianTime.now.advanced(by: .hours(1))
55
55
56
56
let date = iPhoneAnnounceTime.date(day: GregorianDay.today) // => Date
57
57
```
@@ -120,7 +120,7 @@ Note that the ``Debouncer`` was stored in a property so ``Debouncer/cancelAll()`
Copy file name to clipboardExpand all lines: Sources/HandySwift/Types/GregorianTime.swift
+37-20
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,13 @@ import Foundation
2
2
3
3
/// A time without date info.
4
4
///
5
-
/// `GregorianTimeOfDay` represents a time of day without any associated date information. It provides functionalities to work with time components like hour, minute, and second, and perform operations such as initializing from a given date, calculating durations, advancing, and reversing time.
5
+
/// `GregorianTime` represents a time of day without any associated date information. It provides functionalities to work with time components like hour, minute, and second, and perform operations such as initializing from a given date, calculating durations, advancing, and reversing time.
6
6
///
7
7
/// Example:
8
8
/// ```swift
9
9
/// // Initializing from a given date
10
10
/// let date = Date()
11
-
/// let timeOfDay = GregorianTimeOfDay(date: date)
11
+
/// let timeOfDay = GregorianTime(date: date)
12
12
///
13
13
/// // Calculating duration since the start of the day
14
14
/// let durationSinceStartOfDay: Duration = timeOfDay.durationSinceStartOfDay
@@ -20,7 +20,7 @@ import Foundation
20
20
/// // Reversing time by a duration
21
21
/// let reversedTime = timeOfDay.reversed(by: .minutes(15))
22
22
/// ```
23
-
publicstructGregorianTimeOfDay{
23
+
publicstructGregorianTime{
24
24
/// The number of days beyond the current day.
25
25
publicvaroverflowingDays:Int
26
26
/// The hour component of the time.
@@ -30,7 +30,7 @@ public struct GregorianTimeOfDay {
30
30
/// The second component of the time.
31
31
publicvarsecond:Int
32
32
33
-
/// Initializes a `GregorianTimeOfDay` instance from a given date.
33
+
/// Initializes a `GregorianTime` instance from a given date.
34
34
///
35
35
/// - Parameter date: The date from which to extract time components.
36
36
publicinit(date:Date){
@@ -41,7 +41,7 @@ public struct GregorianTimeOfDay {
41
41
self.second = components.second!
42
42
}
43
43
44
-
/// Initializes a `GregorianTimeOfDay` instance with the provided time components.
44
+
/// Initializes a `GregorianTime` instance with the provided time components.
45
45
///
46
46
/// - Parameters:
47
47
/// - hour: The hour component.
@@ -64,7 +64,7 @@ public struct GregorianTimeOfDay {
64
64
/// - day: The day to which the time belongs.
65
65
/// - timeZone: The time zone to use for the conversion (default is the current time zone).
66
66
/// - Returns: A `Date` object representing the time.
/// Provides backward compatibility for the renamed `GregorianTime` type.
150
+
///
151
+
/// This type has been renamed to ``GregorianTime`` to better reflect its purpose and maintain consistency with other types in the framework.
152
+
///
153
+
/// Instead of using `GregorianTimeOfDay`, use ``GregorianTime``:
154
+
/// ```swift
155
+
/// // Old code:
156
+
/// let time = GregorianTimeOfDay(hour: 14, minute: 30)
157
+
///
158
+
/// // New code:
159
+
/// let time = GregorianTime(hour: 14, minute: 30)
160
+
/// ```
161
+
@available(*, deprecated, renamed:"GregorianTime", message:"Use GregorianTime instead. This type has been renamed for better clarity and consistency.")
0 commit comments