melvitax / DateHelper

A Swift Date extension helper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can we have startOfYear and endOfYear options DateForType?

hemangshah opened this issue · comments

right now, we can get a date object for the following options:

public enum DateForType {
    case startOfDay, endOfDay, startOfWeek, endOfWeek, startOfMonth, endOfMonth, tomorrow, yesterday, nearestMinute(minute:Int), nearestHour(hour:Int)
}

Can we have additional options like:

startOfYear and endOfYear.

Usage example:

let date = Date()
let df = DateFormatter()
df.dateFormat = "yyyy-MM-dd"
let fromDate: String = df.string(from: date.dateFor(.startOfYear))
let toDate: String = df.string(from: date.dateFor(.endOfYear))

This has now been added to the 4.5.0 release