Thought I'd give it a go, just to see what I'd need to change for my local non-Umbraco environments (where I don't have access to the umbraco.library, only the exslt.org extensions) - so here's a Exslt-only version (there's an exslt-equivalent for msxml:node-set() which I couldn't find in the Umbraco version of Exslt) - enough already, here's the stuff:
(So the "date" prefix is mapped to the URI "urn:Exslt.ExsltDatesAndTimes") - the weird 'P7D' stuff is the "duration" argument to the add() function, which is described here: http://www.w3.org/TR/xmlschema-2/#duration
Also, I use an XML variable to map the value from weekday() to the number of days needed to subtract from today (the name attributes in this variable is entirely for the humans reading it...)
Week Start and End Dates
On a project I've been working on, we need to grab the week start date and end date (assuming it starts on Monday).
I had a look around on the internet and found some very good code, but it was a bit epic at over 150 lines!
So I've quickly shrunk it down using some Umbraco helper methods. Just posting it up here as it may help someone use and save them a few hours.
Any further shrinks are more than welcomed! ;) Lau
Hi Laurence,
Thought I'd give it a go, just to see what I'd need to change for my local non-Umbraco environments (where I don't have access to the umbraco.library, only the exslt.org extensions) - so here's a Exslt-only version (there's an exslt-equivalent for msxml:node-set() which I couldn't find in the Umbraco version of Exslt) - enough already, here's the stuff:
(So the "date" prefix is mapped to the URI "urn:Exslt.ExsltDatesAndTimes") - the weird 'P7D' stuff is the "duration" argument to the add() function, which is described here: http://www.w3.org/TR/xmlschema-2/#duration
Also, I use an XML variable to map the value from weekday() to the number of days needed to subtract from today (the name attributes in this variable is entirely for the humans reading it...)
Cheers,
Chriztian
Hello Chriztian,
I tried to use your piece of code with no luck, actually the preffix date is not defined.
Any ideas?
Cheers, Giorgos
Hi Giorgios,
No - that part was left out (but I explained in below the code).
Ususlly, the prefixes are mapped to a namespace URI on the root element of an XML file, in this case the xsl:stylesheet element:
The dots (...) refers to additional definition/exclusions that may already be there.
/Chriztian
Oh yes,
I thought it was already there! Now it's fine, thanks a lot.
Giorgos
is working on a reply...