Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Date red/rebol:减去日期返回天数,如何更改?_Date_Types_Rebol_Red - Fatal编程技术网

Date red/rebol:减去日期返回天数,如何更改?

Date red/rebol:减去日期返回天数,如何更改?,date,types,rebol,red,Date,Types,Rebol,Red,使用日期类型,我想知道为什么减法总是返回天,如何使它返回分钟(或秒等),这在第二个示例中是可能的 >> 24-dec-2016 - now == 82 >> 24-dec-2016/0:00 - now == 82 这是任意的还是我可以影响返回的内容?我尝试了一些改进,但希望能朝着rebol/red的方向努力 也许在这个问题下面还有一个更重要的问题:减法的“规则”是什么,常识,某种讨论和共识,还是仅仅由谁来实施决定?(例如,减法的结果:1.1.1.1-1,200x200

使用日期类型,我想知道为什么减法总是返回天,如何使它返回分钟(或秒等),这在第二个示例中是可能的

>> 24-dec-2016 - now
== 82
>> 24-dec-2016/0:00 - now
== 82
这是任意的还是我可以影响返回的内容?我尝试了一些改进,但希望能朝着rebol/red的方向努力


也许在这个问题下面还有一个更重要的问题:减法的“规则”是什么,常识,某种讨论和共识,还是仅仅由谁来实施决定?(例如,减法的结果:
1.1.1.1-1
200x200-100
,…)

您可以使用
差分

difference 24-dec-2016 now
== 1952:06:01
要获取特定零件,请使用路径语法:

time-diff: difference 24-dec-2016 now
time-diff/2
给出分钟数(第二部分)

✓ 退房

如果您加载它,即

do http://www.rebol.org/download-a-script.r?script-name=date-time.r
然后你可以这样做:

>> ? date-dif
USAGE:
  DATE-DIF date1 date2 /y /m /d /ym /md /yd

DESCRIPTION:

  Returns the difference between two dates.

   DATE-DIF is a function value.

ARGUMENTS:
   date1 -- (Type: date)
   date2 -- (Type: date)
REFINEMENTS:
   /y -- Returns the number of complete years between @date1
and @date2.
   /m -- Returns the number of complete months between @date
1 and @date2.
   /d -- Returns the number of complete days between @date1
and @date2.
   /ym -- Returns the number of full months between @date1 a
nd @date2,
      not including the difference in years.
   /md -- Returns the number of full days between @date1 and
@date2,
      not including the difference in months.
   /yd -- Returns the number of full days between @date1 and
@date2,
      not including the difference in years.
✓ <代码>>>?现在查看日期的/优化

>> ? now
USAGE:
    NOW /year /month /day /time /zone /date /weekday /yearday
/precise

DESCRIPTION:
     Returns the current local date and time.
     NOW is a native value.

REFINEMENTS:
     /year -- Returns the year only.
     /month -- Returns the month only.
     /day -- Returns the day of the month only.
     /time -- Returns the time only.
     /zone -- Returns the time zone offset from GMT only.
     /date -- Returns date only.
     /weekday -- Returns day of the week as integer (Monday is
 day 1).
     /yearday -- Returns day of the year (Julian)
     /precise -- Use nanosecond precision
例如:

>> d: 27-7-1973
== 27-Jul-1973
>> d/day
== 27
>> d/month
== 7
>> d/year
== 1973
此外,你可以做整数!获取秒数的时间差。
>> d: 27-7-1973
== 27-Jul-1973
>> d/day
== 27
>> d/month
== 7
>> d/year
== 1973