ISO 8601持续时间“ P1M”的值是多少(以秒为单位)? [英] What is the value of the ISO 8601 duration `P1M` (in seconds)?

查看:367
本文介绍了ISO 8601持续时间“ P1M”的值是多少(以秒为单位)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的ISO持续时间为ISO 8601,表示为 P1M 。通俗地说,这意味着一个月。假设不知道开始日期,是否存在将其转换为秒数的标准规则?

Suppose I have an ISO 8601 duration, expressed as "P1M". Phrased colloquially, this means "one month." Is there a standard rule for converting this into a number of seconds, assuming the start date is not known?


  • 在30个月的时间里,它可能是2,592,000。

  • 在31天中,可能是2,678,400。

  • 2月,它可能是2,419,200或2,505,600

我的直觉说,无法在不知道上下文的情况下将一个月解析为确切的秒数,以及这些秒数在哪里布置在日历上。但是,是否有标准的规则/惯例以抽象的方式计算这些持续时间?

My gut says there's no way to resolve "one month" to an exact number of seconds without knowing context, and where those seconds are laid out on the calendar. But are there standard rules/conventions to calculate these durations in an abstract way?

推荐答案

从我发现的ISO 8601文档中(第6- http://xml.coverpages.org/ISO-FDIS-8601.pdf),看来您是正确的,因为无法确定一个月中的秒数。但是,它确实指出在某些应用程序中,一个月被视为30天的时间单位,因此根据您的应用程序,这可能是一种有效的方法。

From ISO 8601 documentation that I found (page 6 - http://xml.coverpages.org/ISO-FDIS-8601.pdf), it seems you are correct in that the number of seconds in a month cannot definitively be determined. However it does note that "In certain applications a month is regarded as a unit of time of 30 days", so depending on your application this may be a valid approach.

有时,日历时间(年,月等)与绝对时间(小时,分钟,秒等)之间的区别很重要。例如,有些人可能抱怨如果他们每30天而不是每月支付30年,则几年要还13笔抵押贷款。

The distinction between "Calendar Time" (Years, Months, etc) and "Absolute Time" (Hours, Minutes, Seconds, etc) is sometimes an important one. As an example, some people might complain about having 13 mortgage payments some years if they paid every 30 days as opposed to every month.

这篇关于ISO 8601持续时间“ P1M”的值是多少(以秒为单位)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆