Comment detail

除算・余剰を使わずに閏年 (Nested Flatten)

This comment is reply for 5369 sumim: その手がありましたか!って、もはや悪のり...(除算・余剰を使わずに閏年). Go to thread root.

そうか、その手が。。。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:fn="http://www.w3.org/2005/xpath-functions"
  >

  <xsl:output method="text" />

  <xsl:template match="/" >
    <xsl:for-each select="1900 to 2100">
      <xsl:variable name="thisYear" as="xs:date"
        select="xs:date(fn:concat(xs:string(.), '-01-01'))" />
      <xsl:variable name="nextYear" as="xs:date"
        select="xs:date(fn:concat(xs:string(1+.), '-01-01'))" />
      <xsl:if test="fn:days-from-duration($nextYear - $thisYear)=366">
        <xsl:value-of select="." />
        <xsl:text> 年は閏年♪&#xA;</xsl:text>
      </xsl:if>
    </xsl:for-each>
  </xsl:template>

</xsl:stylesheet>

Index

Feed

Other

Link

Pathtraq

loading...