将日期(年月日)转换为天数 [英] Convert date (year month day) to day count
本文介绍了将日期(年月日)转换为天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望给定3⍴⎕TS
的函数(使用公历规则)将返回1+自1 1 1开始的天数.如果函数名为X
,则为EG:
I would like a function (using Gregorian calendar rules) given 3⍴⎕TS
would return 1+ the number of days since 1 1 1. EG if the function were named X
:
X¨ (1 1 1) (1 12 31) (2 12 31) (3 12 31) (4 12 31)
1 365 730 1095 1461
我需要这个,所以我可以减去两个日期以找出它们之间的天数.
I need this so I can subtract two dates to find the number of days between them.
推荐答案
请参见以下示例-函数X假定索引原点1如下:
Please see the following example - function X assumes index origin 1 as follows:
r←X b
r←(0 31 59 90 120 151 181 212 243 273 304 334)[b[2]]
r←r+b[3]+(365×b[1]-1)+-/⌊(b[1]-3>b[2])÷4 100 400
这篇关于将日期(年月日)转换为天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文