小编Mau*_*ira的帖子

在64位unix PHP上2038之后转换为UTC时出错

我需要在Centos 7.4 64位上使用php(5.4)将日期时间信息从本地时间(gtm + 1)转换为UTC

我尝试了以下程序:

function convertToUtc ($date)
{
  $dateTime = new DateTime ($date, new DateTimeZone('Europe/Rome'));
  $dateTime->setTimezone(new DateTimeZone('UTC'));
  return $dateTime->format('Y-m-d') . 'T' . $dateTime->format('H:i:s') . 'Z';
}
Run Code Online (Sandbox Code Playgroud)

这工作到2038年之后,它错误地计算DST总是返回1小时的偏移量:

2037:一切都好

LOCAL TIME           ->  UTC TIME

2037-03-28 10:12:13  ->  2037-03-28T09:12:13Z   the day before dst change

2037-03-29 10:12:13  ->  2037-03-29T08:12:13Z   the first DST day

2037-10-24 10:12:13  ->  2037-10-24T08:12:13Z   the last DST day

2037-10-25 10:12:13  ->  2037-10-25T09:12:13Z   the day after


2038 : ok until dst change

2038-03-27 10:12:13  ->  2038-03-27T09:12:13Z   OK

2038-03-28 10:12:13 …
Run Code Online (Sandbox Code Playgroud)

php datetime utc year2038 tzdata

8
推荐指数
1
解决办法
128
查看次数

字符串 blit 失败并出现错误:此表达式的类型为字符串,但应为字节类型的表达式

在尝试编译以下表达式时:

String.blit (String.make tfs.len ' ') 0 tfs.txt 0 tfs.len;
Run Code Online (Sandbox Code Playgroud)

编译器抱怨以下错误:

Error: This expression has type string but an expression was expected of type bytes
and the variable 'tfs.txt' (of type string) is pointed at.
Run Code Online (Sandbox Code Playgroud)

正如某些论坛中所建议的那样,我尝试将变量OCAMLPARAM设置为值:safe_string=0,_ 但没有结果

我在 Ubuntu 20.01.01 LTS 下使用 OCaml 4.11.1

ocaml

1
推荐指数
1
解决办法
144
查看次数

这是Delphi Xe8编译器错误吗?

以下语句正确编译:

procedure test ;
var    xx : string;
begin
   xx := 'a' + '}' + 'b';
end;
Run Code Online (Sandbox Code Playgroud)

如果您尝试使用块注释进行注释,则编译器会错误地将文本中的右括号视为注释的结尾.

procedure test ;
var    xx : string;
begin
  {   xx := 'a' + '}' + 'b';  }
end;
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

delphi delphi-xe8

0
推荐指数
1
解决办法
166
查看次数

双类型Functor定义被拒绝

为什么这个算符定义被拒绝了?

data Second a b = Ok a b | Ko a b deriving (Show)

instance Functor (Second x) where
  fmap f (Ok a b ) = Ok (f a) b
  fmap f (Ko a b ) = Ko a (f b) 
Run Code Online (Sandbox Code Playgroud)

收到很多错误:

GHCi, version 8.0.1

main.hs:4:22: error:
    • Couldn't match type ‘b’ with ‘x’
      ‘b’ is a rigid type variable bound by
        the type signature for:
          fmap :: forall a b. (a -> b) -> Second x …
Run Code Online (Sandbox Code Playgroud)

haskell types compiler-errors functor

-2
推荐指数
1
解决办法
112
查看次数