[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: quarter code for date
From: |
Pádraig Brady |
Subject: |
Re: quarter code for date |
Date: |
Thu, 6 Oct 2016 12:53:41 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
On 06/10/16 11:11, john woods wrote:
> date +%YW%V gives week and year; it would be nice if date +%YQ%q could
> return, eg 2016Q3 as having a quarters code in date would save AWKwardness
> or shell arithmetic.
>
> Perhaps we could have
> %q 1,2,3,4
> %Q 1st quarter; 2nd quarter; 3rd quarter; 4th quarter
>
> Regards ...
This is one of those marginal calls.
It's not that awkward to get the quarter number: $(( ($(date +%-m)-1)/3+1 ))
But I agree it would be useful to give the number directly.
Note you may want to raise your proposal with the glibc team also in their
strftime(3) interface; coreutils is hesitant to add new % modifiers in
date(1) without prior practice from C libraries.
Note ruby uses %Q to give the number of milliseconds since epoch.
So we might skip that?
BTW 1 -> 1st etc. functionality might be useful to add to numfmt(1).
Note perl Date::Format uses %q to give the quarter number, starting with 1
I'd be 60:40 for adding it.
thanks,
Pádraig