LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   date gives out wrong week number (http://www.linuxquestions.org/questions/slackware-14/date-gives-out-wrong-week-number-4175446426/)

number22 01-20-2013 12:25 AM

date gives out wrong week number
 
week number from string format for time are wrong, date +%W gives wrong week number, need a fix.

ponce 01-20-2013 12:29 AM

I just launched it
Code:

$ date +%W
02
$ cal
    January 2013   
Su Mo Tu We Th Fr Sa
      1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

from "man date"
Code:

%W    week number of year, with Monday as first day of week (00..53)
seems ok to me (the first week is 00). :)

wildwizard 01-20-2013 01:50 AM

Depending on what the OP really wants they could try either %V or %U

%U uses Sunday as the first day of the week (starts at 00 same as %W)
%V uses Monday as the first day of the week and starts at 01 instead of 00

linosaurusroot 01-20-2013 02:00 AM

Quote:

Originally Posted by number22 (Post 4873892)
week number from string format for time are wrong, date +%W gives wrong week number, need a fix.

You have not shown what you got or why you believe it is wrong.

whizje 01-20-2013 03:31 AM

According to ISO 8601 it's week 3. http://en.wikipedia.org/wiki/Seven-d...Week_numbering

wildwizard 01-20-2013 04:34 AM

Quote:

Originally Posted by whizje (Post 4873953)

Which is what %V is for.

But the OP hasn't replied why they think it's wrong.

ponce 01-20-2013 04:34 AM

still from "man date"
Code:

%V    ISO week number, with Monday as first day of week (01..53)
as wildwizard hinted above.

EDIT: ups, beaten.

colucix 01-20-2013 07:28 AM

@number22: it's difficult to provide help if we don't know what the problem really is. We can only guess. Please, translate "gives wrong week number". What number? What is it supposed to be?

number22 01-20-2013 08:17 AM

I thought it should be 03, sorry, I was heading back to bed right after I posted this, didn't realized fast response. Especially to wildwizard, gave me the best answer, switch my script to %V.


All times are GMT -5. The time now is 03:03 AM.