ISO8601 持续时间 'months' 和 'years' 有多少天?
How many days in ISO8601 duration 'months' and 'years'?
我需要代表 100 天的持续时间。
来自Wikipedia:
Durations are represented by the format P[n]Y[n]M[n]DT[n]H[n]M[n]S
但是对于持续时间,一个月有多少天?当然这取决于我们在哪个月...同上,一年中的天数。
跟进, it looks like it's perfectly legal to specify a count larger than the number of units that make up the next "larger" unit, so you could just use P100D
. Wikipedia says:
The standard does not prohibit date and time values in a duration representation from exceeding their "carry over points" except as noted below. Thus, "PT36H" could be used as well as "P1DT12H" for representing the same duration. But keep in mind that "PT36H" is not the same as "P1DT12H" when switching from or to Daylight saving time.
虽然这个例子是几个小时,但似乎几天也应该没问题(而且正如你的问题所说明的那样,更有用,因为月份和年份不是固定的数量)。也就是说,标准没有规定每个单位的最大位数,只是:
Leading zeros are not required, but the maximum number of digits for each element should be agreed to by the communicating parties.
因此,无论什么消耗你的持续时间,每个元素都必须接受至少 3 位数字,P100D
才能工作;这似乎不像是异常高水平的所需支持。
我需要代表 100 天的持续时间。
来自Wikipedia:
Durations are represented by the format P[n]Y[n]M[n]DT[n]H[n]M[n]S
但是对于持续时间,一个月有多少天?当然这取决于我们在哪个月...同上,一年中的天数。
跟进P100D
. Wikipedia says:
The standard does not prohibit date and time values in a duration representation from exceeding their "carry over points" except as noted below. Thus, "PT36H" could be used as well as "P1DT12H" for representing the same duration. But keep in mind that "PT36H" is not the same as "P1DT12H" when switching from or to Daylight saving time.
虽然这个例子是几个小时,但似乎几天也应该没问题(而且正如你的问题所说明的那样,更有用,因为月份和年份不是固定的数量)。也就是说,标准没有规定每个单位的最大位数,只是:
Leading zeros are not required, but the maximum number of digits for each element should be agreed to by the communicating parties.
因此,无论什么消耗你的持续时间,每个元素都必须接受至少 3 位数字,P100D
才能工作;这似乎不像是异常高水平的所需支持。