Linuxwochen Eisenstadt 2008

On Mai the 30th & 31st the Austrian “Linuxwochen” will again hit my former university in Eisenstadt.
Look ahead for some very interesting talks by several highly skilled people.

One event I’d especially like to draw your attention to is Oliver’s pice about “Linux Server Experience with VServer” on Fr. the 30th. at 17:15 hours.

I’d be happy (and I’m sure, Olli even more) to see a lot of people attending this great event, listening to the talks held there and discuss open source solutions with us :)

/dev/null in C#

If you need to direct output into the void in your program on a *NIX system you simply pipe or redirect it to the null device /dev/null.
Needing a similar functionality today in a C# .NET project I found the following equivalent:

Stream.Null

Seemed fairly useful to me ;)

XSLT: convert ISO 8601 DateTime format

Today I did a little bit of XSLT coding and stumbled over the problem to convert ISO 8601 date strings into a more human readable format.

Specifically I wanted to turn a date of the form 2008-04-10T16:12:27Z to the typical german format of 10.04.2008 16:12:27 and spit the whole thing out as HTML to display it on a webpage.
After a bit of time I came up with the following XSLT (sanitized):

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="html"/>
        <xsl:template match="/">
                <xsl:element name="div">
                <xsl:element name="abbr">
                        <xsl:attribute name="title">
                                <xsl:value-of select="create_dt"/>
                                <xsl:value-of select="’Z’"/>
                        </xsl:attribute>
                        <xsl:attribute name="class">dtstart</xsl:attribute>
                        <xsl:call-template name="FormatDate">
                                <xsl:with-param name="DateTime" select="create_dt"/>
                        </xsl:call-template>
                </xsl:element>
                </xsl:element>
        </xsl:template>
        <xsl:template name="FormatDate">
        <xsl:param name="DateTime" />
        <xsl:variable name="mo">
                        <xsl:value-of select="substring($DateTime,6,2)" />
        </xsl:variable>
        <xsl:variable name="day">
                        <xsl:value-of select="substring($DateTime,9,2)" />
          </xsl:variable>
        <xsl:variable name="year">
                        <xsl:value-of select="substring($DateTime,1,4)" />
        </xsl:variable>
        <xsl:variable name="time">
                        <xsl:value-of select="substring($DateTime,12,8)" />
        </xsl:variable>
        <xsl:variable name="hh">
                        <xsl:value-of select="substring($time,1,2)" />
        </xsl:variable>
        <xsl:variable name="mm">
                        <xsl:value-of select="substring($time,4,2)" />
        </xsl:variable>
        <xsl:variable name="ss">
                        <xsl:value-of select="substring($time,7,2)" />
        </xsl:variable>
                <xsl:value-of select="$day"/>
                <xsl:value-of select="’.’"/>
                <xsl:value-of select="$mo"/>
                <xsl:value-of select="’.’"/>
                <xsl:value-of select="$year"/>
                <xsl:value-of select="’ ‘"/>
                <xsl:value-of select="$hh"/>
                <xsl:value-of select="':’"/>
                <xsl:value-of select="$mm"/>
                <xsl:value-of select="':’"/>
                <xsl:value-of select="$ss"/>
        </xsl:template>
</xsl:stylesheet>
 

Using this example and the mighty power of substring() it should be pretty easy to convert any date format into an other one.