Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10949 > unrolled thread
| Started by | Murta <rodrigomurtax@gmail.com> |
|---|---|
| First post | 2012-07-16 03:45 +0000 |
| Last post | 2012-07-16 03:45 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
IsoWeek Function Murta <rodrigomurtax@gmail.com> - 2012-07-16 03:45 +0000
| From | Murta <rodrigomurtax@gmail.com> |
|---|---|
| Date | 2012-07-16 03:45 +0000 |
| Subject | IsoWeek Function |
| Message-ID | <ju02pc$48m$1@smc.vnet.net> |
Hi All
Please, in Mathematica 9 include IsoWeek functions in the standard into DateList and DateString. It would be simple if we have a "ISOWeekYear" and "ISOWeekNumber" as in Oracle and SQL.
Today it's necessary to implemente our own functions, and I get very slow performance results.
I use that to take ISO Week numbers:
ISOWeek[x_]:=Module[{baseDate,year454,weekNames,numWeek},
weekNames={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
year454=First@DateList@DatePlus[x,-Position[weekNames,DateString[DatePlus[x,-1],{"DayName"}],1][[1,1]]+4];
baseDate={year454,1,3};
numWeek=IntegerPart[1/7(DateDifference[baseDate,x]+Position[weekNames,DateString[baseDate,{"DayName"}],1][[1,1]]+5)];
{year454,numWeek}
]
Example
ISOWeek["20120101"]
{2011,52}
I tried to compile it, but with no sucess..
Any clue?
Another tip for the developer is create an string "WeekDayNumber", that can return the week day number. Today we have option just to names.
tks in advance
Murta
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web