bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: date


From: Jeremy M. Guthrie
Subject: Re: date
Date: Wed, 31 Dec 2008 11:40:25 -0600
User-agent: KMail/1.9.7

Ah, that explains it!  Thanks.

On Wednesday 31 December 2008, Bob Proulx wrote:
> Jeremy M. Guthrie wrote:
> > I have found a bug with 'date', it will jump a year the last few days of
> > the year.
>
> Thank you for your report.  But the behavior you are reporting is not
> a bug but a misunderstanding of the date format specifications.
>
> > #The actual time/date
> > [h-custmgmt-msn-1 guthrie 10:09am]~-> date
> > Wed Dec 31 10:09:34 CST 2008
>
> This probably isn't the issue but the default legacy date format is
> ambiguous.  CST isn't unique.  For future reference using -R is a
> better format and is found my places such as in mail date strings and
> so forth.  This is just a hint for the future.
>
>   $ date -R
>   Wed, 31 Dec 2008 10:28:33 -0700
>
> > #It thinks it's 2009.  It did this yesterday and the day before.
> > [h-custmgmt-msn-1 guthrie 10:09am]~-> date "+%m-%d-%G"
> > 12-31-2009
> > [h-custmgmt-msn-1 guthrie 10:09am]~-> date "+%G"
> > 2009
>
> That is true all week long.  The %G is as shown:
>
>   `%G'
>        The year corresponding to the ISO week number.  This has the same
>        format and value as `%Y', except that if the ISO week number (see
>        `%V') belongs to the previous or next year, that year is used
>        instead.  This is a GNU extension.
>
> The ISO week number is 2009.  What you wanted was %Y if you wanted the
> year in the current calendar year.
>
>   `%Y'
>        year.  This is normally at least four characters, but it may be
>        more.  Year `0000' precedes year `0001', and year `-001' precedes
>        year `0000'.
>
>
> Try this:
>
>   $ date "+%m-%d-%Y"
>   12-31-2008
>
> Or better yet use the %F format specifying to use the full date in ISO
> format.  This is a GNU extension.
>
>   $ date +%F
>   2008-12-31
>
> Bob



-- 

--------------------------------------------------
Jeremy M. Guthrie           address@hidden
Hosting and Managed Services
Cisco Managed Security Services
Technical Architect            Phone: 608-298-1061
CDW                              Fax: 608-288-3007
5520 Research Park Drive         NOC: 608-298-1102
Madison, WI 53711

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]