LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 01-20-2013, 12:25 AM   #1
number22
Member
 
Registered: Sep 2006
Location: Earth
Distribution: Slackware 14.1 Slackware64-current multilib
Posts: 187
Blog Entries: 1

Rep: Reputation: 38
date gives out wrong week number


week number from string format for time are wrong, date +%W gives wrong week number, need a fix.
 
Old 01-20-2013, 12:29 AM   #2
ponce
Senior Member
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 2,457

Rep: Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886
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).
 
1 members found this post helpful.
Old 01-20-2013, 01:50 AM   #3
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 755

Rep: Reputation: 226Reputation: 226Reputation: 226
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
 
1 members found this post helpful.
Old 01-20-2013, 02:00 AM   #4
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 802
Blog Entries: 2

Rep: Reputation: 203Reputation: 203Reputation: 203
Quote:
Originally Posted by number22 View Post
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.
 
Old 01-20-2013, 03:31 AM   #5
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 583

Rep: Reputation: 129Reputation: 129
According to ISO 8601 it's week 3. http://en.wikipedia.org/wiki/Seven-d...Week_numbering
 
1 members found this post helpful.
Old 01-20-2013, 04:34 AM   #6
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 755

Rep: Reputation: 226Reputation: 226Reputation: 226
Quote:
Originally Posted by whizje View Post
Which is what %V is for.

But the OP hasn't replied why they think it's wrong.
 
1 members found this post helpful.
Old 01-20-2013, 04:34 AM   #7
ponce
Senior Member
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 2,457

Rep: Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886
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.

Last edited by ponce; 01-20-2013 at 04:40 AM.
 
Old 01-20-2013, 07:28 AM   #8
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,508

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
@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?
 
Old 01-20-2013, 08:17 AM   #9
number22
Member
 
Registered: Sep 2006
Location: Earth
Distribution: Slackware 14.1 Slackware64-current multilib
Posts: 187
Blog Entries: 1

Original Poster
Rep: Reputation: 38
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with calendar with only week number ANU Programming 1 04-27-2012 08:24 AM
any lang: week number ezekieldas Programming 13 03-30-2012 03:50 PM
oracle + working with date/week champ Programming 8 11-28-2011 05:45 PM
remove week numbers from date navigator in kontact gub Linux - Desktop 0 01-20-2007 01:30 AM
Getting Day of Week - Java - SQL Date MRMadhav Programming 4 04-03-2006 12:01 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration