How to get the current day number in current month and year
<p>I am using this code to get the number of day in the current week:</p>

<pre><code>static func currentDayOfWeek() -&gt; Int {
    let comp = NSCalendar.current.dateComponents([.weekday], from: Date())
    if comp.weekday == 1 {
        return 7
    }

    return comp.weekday! - 1
}

Monday =  1
Tuesday = 2
...........
Sunday =  7
</code></pre>

<p>I can't manage to figure out how to get the current day number of the month and year.</p>

<p>For example for today current day number for the month should be <code>3</code> and for the year it should be <code>277</code>.</p>

<p>Any suggestions ?</p>