Skip to content

Commit

Permalink
Post date now is DateTime object
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiCMueller committed Feb 16, 2017
1 parent a2d5912 commit 0838f11
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ composer.phar update

## Versions

* 2.0.0 - Post date now is DateTime object
* 1.0.1 - Adjusting Readme for correct versioning
* 1.0.0 - First release version
24 changes: 17 additions & 7 deletions src/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class Processor
const DATA_KEY_PAYLOAD_REFERENCES = 'references';
const DATA_KEY_PAYLOAD_REFERENCES_POST = 'Post';
const DATA_KEY_PAYLOAD_REFERENCES_POST_TITLE = 'title';
const DATA_KEY_PAYLOAD_REFERENCES_POST_FIRSTPUBLISHEDAT = 'firstPublishedAt';
const DATA_KEY_PAYLOAD_REFERENCES_POST_CONTENT = 'content';
const DATA_KEY_PAYLOAD_REFERENCES_POST_CONTENT_SUBTITLE = 'subtitle';
const DATA_KEY_PAYLOAD_REFERENCES_POST_UNIQUESLUG = 'uniqueSlug';
const DATA_KEY_PAYLOAD_REFERENCES_POST_VIRTUALS = 'virtuals';
const DATA_KEY_PAYLOAD_REFERENCES_POST_VIRTUALS_TAGS = 'tags';
const DATA_KEY_PAYLOAD_REFERENCES_POST_VIRTUALS_TAGS_NAME = 'name';
const DATA_KEY_PAYLOAD_REFERENCES_POST_VIRTUALS_FIRSTPUBLISHEDATENGLISH = 'firstPublishedAtEnglish';

/**
* @var \KaiCMueller\Medium\Config
Expand Down Expand Up @@ -129,12 +129,13 @@ public function process($rawData)
$post
),
self::POST_KEY_DATE =>
$this->getArrayData(
[
self::DATA_KEY_PAYLOAD_REFERENCES_POST_VIRTUALS,
self::DATA_KEY_PAYLOAD_REFERENCES_POST_VIRTUALS_FIRSTPUBLISHEDATENGLISH
],
$post
$this->microtimeToDate(
$this->getArrayData(
[
self::DATA_KEY_PAYLOAD_REFERENCES_POST_FIRSTPUBLISHEDAT,
],
$post
)
),
self::POST_KEY_TAGS => $tags
];
Expand Down Expand Up @@ -184,4 +185,13 @@ protected function decode($rawData)
return $decodedData;
}

/**
* @param int $microtime
* @return \DateTime
*/
protected function microtimeToDate($microtime)
{
return \DateTime::createFromFormat('U', intval($microtime / 1000));
}

}

0 comments on commit 0838f11

Please sign in to comment.