mirror of
https://github.com/typecho/typecho.git
synced 2025-04-21 02:01:52 +02:00
Fix timezone error in XmlRpc (#1758)
Signed-off-by: Kraity <kraity@krait.cn>
This commit is contained in:
parent
4ce9cdefc2
commit
31f5192c9d
@ -9,17 +9,19 @@ namespace IXR;
|
||||
*/
|
||||
class Date
|
||||
{
|
||||
private int $year;
|
||||
private string $year;
|
||||
|
||||
private int $month;
|
||||
private string $month;
|
||||
|
||||
private int $day;
|
||||
private string $day;
|
||||
|
||||
private int $hour;
|
||||
private string $hour;
|
||||
|
||||
private int $minute;
|
||||
private string $minute;
|
||||
|
||||
private int $second;
|
||||
private string $second;
|
||||
|
||||
private string $timezone;
|
||||
|
||||
/**
|
||||
* @param int|string $time
|
||||
@ -39,12 +41,13 @@ class Date
|
||||
*/
|
||||
private function parseTimestamp(int $timestamp)
|
||||
{
|
||||
$this->year = intval(date('Y', $timestamp));
|
||||
$this->month = intval(date('m', $timestamp));
|
||||
$this->day = intval(date('d', $timestamp));
|
||||
$this->hour = intval(date('H', $timestamp));
|
||||
$this->minute = intval(date('i', $timestamp));
|
||||
$this->second = intval(date('s', $timestamp));
|
||||
$this->year = gmdate('Y', $timestamp);
|
||||
$this->month = gmdate('m', $timestamp);
|
||||
$this->day = gmdate('d', $timestamp);
|
||||
$this->hour = gmdate('H', $timestamp);
|
||||
$this->minute = gmdate('i', $timestamp);
|
||||
$this->second = gmdate('s', $timestamp);
|
||||
$this->timezone = '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,6 +61,7 @@ class Date
|
||||
$this->hour = substr($iso, 9, 2);
|
||||
$this->minute = substr($iso, 12, 2);
|
||||
$this->second = substr($iso, 15, 2);
|
||||
$this->timezone = substr($iso, 17);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,7 +69,7 @@ class Date
|
||||
*/
|
||||
public function getIso(): string
|
||||
{
|
||||
return $this->year . $this->month . $this->day . 'T' . $this->hour . ':' . $this->minute . ':' . $this->second;
|
||||
return $this->year . $this->month . $this->day . 'T' . $this->hour . ':' . $this->minute . ':' . $this->second . $this->timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -576,7 +576,7 @@ class XmlRpc extends Contents implements ActionInterface, Hook
|
||||
while ($pages->next()) {
|
||||
$pageStructs[] = [
|
||||
'dateCreated' => new Date($this->options->timezone + $pages->created),
|
||||
'date_created_gmt' => new Date($this->options->timezone + $pages->created),
|
||||
'date_created_gmt' => new Date($pages->created),
|
||||
'page_id' => $pages->cid,
|
||||
'page_title' => $pages->title,
|
||||
'page_parent_id' => '0',
|
||||
@ -945,7 +945,7 @@ class XmlRpc extends Contents implements ActionInterface, Hook
|
||||
}
|
||||
|
||||
return [
|
||||
'date_created_gmt' => new Date($this->options->timezone + $comment->created),
|
||||
'date_created_gmt' => new Date($comment->created),
|
||||
'user_id' => $comment->authorId,
|
||||
'comment_id' => $comment->coid,
|
||||
'parent' => $comment->parent,
|
||||
@ -999,7 +999,7 @@ class XmlRpc extends Contents implements ActionInterface, Hook
|
||||
|
||||
while ($comments->next()) {
|
||||
$commentsStruct[] = [
|
||||
'date_created_gmt' => new Date($this->options->timezone + $comments->created),
|
||||
'date_created_gmt' => new Date($comments->created),
|
||||
'user_id' => $comments->authorId,
|
||||
'comment_id' => $comments->coid,
|
||||
'parent' => $comments->parent,
|
||||
@ -1174,7 +1174,7 @@ class XmlRpc extends Contents implements ActionInterface, Hook
|
||||
while ($attachments->next()) {
|
||||
$attachmentsStruct[] = [
|
||||
'attachment_id' => $attachments->cid,
|
||||
'date_created_gmt' => new Date($this->options->timezone + $attachments->created),
|
||||
'date_created_gmt' => new Date($attachments->created),
|
||||
'parent' => $attachments->parent,
|
||||
'link' => $attachments->attachment->url,
|
||||
'title' => $attachments->title,
|
||||
@ -1205,7 +1205,7 @@ class XmlRpc extends Contents implements ActionInterface, Hook
|
||||
|
||||
return [
|
||||
'attachment_id' => $attachment->cid,
|
||||
'date_created_gmt' => new Date($this->options->timezone + $attachment->created),
|
||||
'date_created_gmt' => new Date($attachment->created),
|
||||
'parent' => $attachment->parent,
|
||||
'link' => $attachment->attachment->url,
|
||||
'title' => $attachment->title,
|
||||
@ -1417,7 +1417,7 @@ class XmlRpc extends Contents implements ActionInterface, Hook
|
||||
'userid' => $posts->authorId,
|
||||
'postid' => $posts->cid,
|
||||
'title' => $posts->title,
|
||||
'date_created_gmt' => new Date($this->options->timezone + $posts->created)
|
||||
'date_created_gmt' => new Date($posts->created)
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user