EXTENSION
public extension Date
var year: Int
Returns the year from the date.
var month: Int
Returns month as Int
starting from 1...12
.
var week: Int
Returns week as Int
starting from 1...52
var weekday: Int
var weekOfMonth: Int
var day: Int
var hour: Int
var minute: Int
var second: Int
var nanos: Int
var yesterday: Date
var today: Date
var tomorrow: Date
var dayAfter: Date
var dayBefore: Date
var isLastDayOfMonth: Bool
var startOfDay: Date
Start of current day
var endOfDay: Date
End of current day
func adjust(_ type: Calendar.Component, offset: Int) -> Date
Offset component by amount
- Parameters:
- type: Component
- offset: Offset to add
- Returns: Date
Name | Description |
---|---|
type | Component |
offset | Offset to add |
func toRelativeFormat(
currentDate: Date = Date(),
numericDates: Bool = true
) -> String
Get relative String back from Date ex: 1 year ago, 1 month ago ...
- Parameters:
- currentDate: Current Date
- numericDates: Display the numeric value in string ex: 1 year ago vs Last year
- Returns: String
Name | Description |
---|---|
currentDate | Current Date |
numericDates | Display the numeric value in string ex: 1 year ago vs Last year |