Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Convert a number to timespan in XSL

Posted on 2006-07-19
3
839 Views
Last Modified: 2010-05-18
Hello,

I am receiving an XML data island from a web application that I then convert to Microsoft Project XML via an xsl stylesheet I am creating.  One of the tags called "Duration" that the Microsoft Project requires is of type "timespan".  An acceptable entry for this is:

<Duration>PT80H0M0S</Duration>

Which I think corresponds to 10 days.  (At least that what my duration value is in MSProject.)

But anyway, in the data island I am receiving has the duration as just an integer, like 10,15, 20, etc in days.  How can I convert it to this type of format in my xsl sheet?  I don't really know what PT80H0M0S means.  

Thanks.
0
Comment
Question by:dentyne
  • 2
3 Comments
 
LVL 9

Expert Comment

by:owenli27
ID: 17141631
I believe that Timespan is NET Framework type.
PT80H0M0S means 80 hours and 0 min and 0 secods.  The second char 'T' means TIME.

A example:
P2Y3M18DT10H0M20S is 2 years, 3 months, 18 days, 10 hours, 0 minutes, and 20 seconds.

if you get your "Duration" days as integer, it is very easy to convert it to Hours by times 24 and concatenate it with rest of string. Do you need XSL code for this?
0
 
LVL 9

Accepted Solution

by:
owenli27 earned 500 total points
ID: 17141768
in case you need this line:  <xsl:value-of select="concat('PT', (text()*24), 'H0M0S')" />
0
 
LVL 1

Author Comment

by:dentyne
ID: 17146442
Hi Owen,

Thanks for the help.  I think this will do the trick.  
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question