XSLT:根据非一月开始计算年份

发布于 2024-08-17 23:20:04 字数 200 浏览 3 评论 0原文

我试图根据 4 月 6 日开始的一年来计算一年。

使用 EXSLT,我可以根据正常的 1 月开始获得年份:

date:formatDate(date:add(date:date(), '-P6Y'), 'yyyy')

除了从 4 月 6 日开始的一年,我怎样才能做同样的事情呢?

谢谢。

I'm trying to calculate a year based on a year starting 6th April.

Using EXSLT I can get the year based on a normal January start:

date:formatDate(date:add(date:date(), '-P6Y'), 'yyyy')

How can I do the same but for a year starting 6th April.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏大泽ㄣ 2024-08-24 23:20:04

像这样的东西

 <xsl:choose>
   <xsl:when test="(date:month-in-year() = 4 and date:day-in-month() <= 6) or (date:month-in-year() < 4)">
     <xsl:value-of select="date:formatDate(date:add(date:date(), '-P7Y'), 'yyyy')" />
   </xsl:when>
   <xsl:otherwise>
     <xsl:value-of select="date:formatDate(date:add(date:date(), '-P6Y'), 'yyyy')" />
  </xsl:otherwise>
</xsl:choose>

Something like this

 <xsl:choose>
   <xsl:when test="(date:month-in-year() = 4 and date:day-in-month() <= 6) or (date:month-in-year() < 4)">
     <xsl:value-of select="date:formatDate(date:add(date:date(), '-P7Y'), 'yyyy')" />
   </xsl:when>
   <xsl:otherwise>
     <xsl:value-of select="date:formatDate(date:add(date:date(), '-P6Y'), 'yyyy')" />
  </xsl:otherwise>
</xsl:choose>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文