Sleek way to calculate quarter in python3

Viewed 375

Is there a sleekest way to calculate the quarter for today's date? I know there are bunch of solutions over here but I am looking for something slick which doesn't need any other library that datetime.

I am currently calculating week by using the following code which gives me output for week: 2017-26

import datetime as DT

varWeek = (str(DT.date.today().isocalendar()[0]) + "-" + 
           str(DT.date.today().isocalendar()[1]))

I need a quarter for today's date in the following format.

'2017-Q2'.

1 Answers
Related