2016-07-10 53 views
2

在我的流明应用程序中,我试图以编程方式创建标签GitHub回购。除了tagger.date我无法弄清楚什么外,我的设置很好。该API是告诉我,时间戳是无效的:无法以编程方式在GitHub中创建标签-ISO8601时间戳无效

[Github\Exception\RuntimeException]     
    Invalid request.          
    2016-07-10T13:32:07+0000 is not a valid date-time. 

但是包含在错误消息的时间戳似乎正确格式化based on the documentation

$github->git()->tags()->create(
     $githubConfig['namespace'], 
     $githubConfig['repository'], 
     [ 
      'tag'  => $this->version->patchTag(), 
      'tagger' => [ 
       'name' => config('github.tagger.name'), 
       'email' => config('github.tagger.email'), 
       'date' => Carbon::now()->toIso8601String() 
      ], 
      'message' => 'This release was automatically published by [Game-Watcher](https://github.com/bkuhl/game-watcher).', 
      'object' => $masterBranch['commit']['sha'], 
      'type'  => 'commit' 
     ] 
    ); 

This fiddle表示时间格式有效。

回答

2

尝试使用Carbon::now()->toAtomString()代替。

Carbon的common formatting methods是“DateTime class中提供的常见格式的包装”。

DateTime::ISO8601的文档进行这样的警告:

注:这种格式与ISO-8601兼容,但留下这样的向后兼容的原因。改为使用DateTime::ATOMDATE_ATOM代替ISO-8601。

相关差异似乎与时区偏移量有关。 DateTime::ISO8601对于UTC使用+0000,而DateTime::ATOM使用+00:00

+1

令人难以置信的令人沮丧的是,他们为了向后兼容而留下了这个问题,甚至更多地让Carbon无法解决这个问题。 – Webnet

+0

同意,@Webnet。海事组织这是应该被修复的事情,特别是因为像你们这样的问题。开发人员应该能够假设ISO8601实际上反映了它的命名标准。我很惊讶它没有在PHP7中修复。 – Chris

+0

@Webnet,我很想知道这是否工作。 – Chris