Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10960

Re: IsoWeek Function

From Murta <rodrigomurtax@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: IsoWeek Function
Date 2012-07-17 05:35 +0000
Message-ID <ju2ti5$s6c$1@smc.vnet.net> (permalink)
References <20120716034417.DD63E6857@smc.vnet.net> <ju0l8s$l00$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


Tks for your attention
I have made some progress, but not enough:

below there is one fast way to get weekDay

weekDayC = Compile[{{ano, _Integer}, {m, _Integer}, {d, _Integer}}
  , Module[{t, y = ano},
   (*2 for Monday*)
   t = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
   y -= Boole[m < 3];
   Mod[y + IntegerPart[y/4.] - IntegerPart[y/100.] + 
     IntegerPart[y/400.] + t[[m]] + d + 1, 7, 1]
   ]
  ]


I used it in my ISOWeek like this

ISOWeekX2[x_] := Module[{baseDate, year454, weekNames, numWeek},
  	year454 = First@DatePlus[x, -Mod[weekDayC @@ x - 1, 7, 1] + 4];
  	baseDate = {year454, 1, 3};
  	numWeek = 
   IntegerPart[
    1/7 (DateDifference[baseDate, x] + weekDayC @@ baseDate + 5)];
  	{year454, numWeek}
  ]

But the there are 2 another slow parts, that are DateDifference and DataPlus. But to get rid of that that is a lot of job..
Native functions would be great...

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: IsoWeek Function "Hans Michel" <hmichel@cox.net> - 2012-07-16 09:01 +0000
  Re: IsoWeek Function Murta <rodrigomurtax@gmail.com> - 2012-07-17 05:35 +0000
  Re: IsoWeek Function "Hans Michel" <hmichel@cox.net> - 2012-07-18 05:37 +0000

csiph-web