ch-gilbert / datejs

Automatically exported from code.google.com/p/datejs
Other
0 stars 0 forks source link

week issue #75

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Date.today().set({week: 10}).getWeek();

What is the expected output? What do you see instead?

expected 10, returns 9

What version of the product are you using? On what operating system?

1.0 Alpha-1 2008-05-13 firefox linux

Please provide any additional information below.

Original issue reported on code.google.com by i...@molinodacapo.de on 5 Jun 2009 at 3:55

GoogleCodeExporter commented 9 years ago
I think there might be a problem in the Alpha-1 release, but the issue has been 
fixed
in svn (http://www.datejs.com/svn/).

Original comment by geoff%co...@gtempaccount.com on 6 Jun 2009 at 10:29

GoogleCodeExporter commented 9 years ago
i am using the svn version. @date: 2008-04-13

Original comment by i...@molinodacapo.de on 7 Jun 2009 at 9:32

GoogleCodeExporter commented 9 years ago

Original comment by geoff%co...@gtempaccount.com on 7 Jun 2009 at 6:58

GoogleCodeExporter commented 9 years ago
$P.getWeek=function(){
    var a,b,c,d,e,f,g,n,s,w;
    $y=(!$y)?this.getFullYear():$y;
    $m=(!$m)?this.getMonth()+1:$m;
    $d=(!$d)?this.getDate():$d;

    if($m<=2){
        a=$y-1;
        b=(a/4|0)-(a/100|0)+(a/400|0);
        c=((a-1)/4|0)-((a-1)/100|0)+((a-1)/400|0);
        s=b-c;
        e=0;
        f=$d-1+(31*($m-1));
//Fix bug week???       
    }else if($m==3){
        a=$y;
        b=(a/4|0)-(a/100|0)+(a/400|0);
        c=((a-1)/4|0)-((a-1)/100|0)+((a-1)/400|0);
        s=b-c;
        e=s+1;
        f=$d+((153*($m-3)+1)/5)+58+s;
        //end
    }else{
        a=$y;
        b=(a/4|0)-(a/100|0)+(a/400|0);
        c=((a-1)/4|0)-((a-1)/100|0)+((a-1)/400|0);
        s=b-c;
        e=s+1;
        f=$d+((153*($m-3)+2)/5)+58+s;       

    }
    g=(a+b)%7;
    d=(f+g-e)%7;
    n=(f+3-d)|0;
    if(n<0){
        w=53-((g-s)/5|0);
    }else if(n>364+s){
        w=1;
    }else{
        w=(n/7|0)+1;
    }
    $y=$m=$d=null;
    return w;
};

Original comment by velozyra...@gmail.com on 4 Sep 2009 at 9:32

GoogleCodeExporter commented 9 years ago
works in the current build on my fork: https://github.com/abritinthebay/datejs/

Original comment by darkcr...@gmail.com on 16 Sep 2013 at 1:31