Skip to content

Commit e3fc0e1

Browse files
committed
fix(helper): Fix missing timestamp on safari (close #12)
1 parent 9970154 commit e3fc0e1

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"authors": [
55
"Jonathan Hornung <[email protected]>"
66
],
7-
"version": "0.7.6",
7+
"version": "0.7.7",
88
"description": "Twitter plugin for apiNG",
99
"main": "dist/aping-plugin-codebird.min.js",
1010
"moduleType": [],

demo/template.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<div class="aping-design-sample">
2-
<div>
3-
<div ng-repeat="item in results">
4-
<pre>{{item | json}}</pre>
5-
</div>
2+
<div ng-repeat="item in results">
3+
<pre>{{item | json}}</pre>
64
</div>
75
</div>

dist/aping-plugin-codebird.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
@name: aping-plugin-codebird
3-
@version: 0.7.6 (24-01-2016)
3+
@version: 0.7.7 (24-01-2016)
44
@author: Jonathan Hornung <[email protected]>
55
@url: https://github.com/JohnnyTheTank/apiNG-plugin-codebird
66
@license: MIT
@@ -251,13 +251,15 @@ angular.module("jtt_aping_codebird")
251251
blog_id: _item.user.id_str,
252252
blog_link: this.getThisPlattformLink() + _item.user.screen_name + "/",
253253
intern_id: _item.id_str,
254-
timestamp: new Date(Date.parse(_item.created_at.replace(/( \+)/, ' UTC$1'))).getTime(),
254+
timestamp: new Date(Date.parse(_item.created_at.replace(/^\w+ (\w+) (\d+) ([\d:]+) \+0000 (\d+)$/, "$1 $2 $4 $3 UTC"))).getTime(),
255255
text: _item.text,
256256
shares: _item.retweet_count,
257257
likes: _item.favorite_count,
258258
});
259259

260-
socialObject.date_time = new Date(socialObject.timestamp);
260+
if(socialObject.timestamp) {
261+
socialObject.date_time = new Date(socialObject.timestamp);
262+
}
261263

262264
if (_item.entities && _item.entities.media && _item.entities.media.length > 0) {
263265
socialObject.source = _item.entities.media;
@@ -286,13 +288,15 @@ angular.module("jtt_aping_codebird")
286288
blog_id: _item.user.id_str,
287289
blog_link: this.getThisPlattformLink() + _item.user.screen_name + "/",
288290
intern_id: _item.id_str,
289-
timestamp: new Date(Date.parse(_item.created_at.replace(/( \+)/, ' UTC$1'))).getTime(),
291+
timestamp: new Date(Date.parse(_item.created_at.replace(/^\w+ (\w+) (\d+) ([\d:]+) \+0000 (\d+)$/, "$1 $2 $4 $3 UTC"))).getTime(),
290292
text: _item.text,
291293
shares: _item.retweet_count,
292294
likes: _item.favorite_count,
293295
});
294296

295-
imageObject.date_time = new Date(imageObject.timestamp);
297+
if(imageObject.timestamp) {
298+
imageObject.date_time = new Date(imageObject.timestamp);
299+
}
296300

297301
if (_item.entities && _item.entities.media && _item.entities.media.length > 0) {
298302

dist/aping-plugin-codebird.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aping-plugin-codebird",
3-
"version": "0.7.6",
3+
"version": "0.7.7",
44
"description": "Twitter plugin for apiNG",
55
"main": "dist/aping-plugin-codebird.min.js",
66
"scripts": {

src/aping-codebird-helper.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,15 @@ angular.module("jtt_aping_codebird")
139139
blog_id: _item.user.id_str,
140140
blog_link: this.getThisPlattformLink() + _item.user.screen_name + "/",
141141
intern_id: _item.id_str,
142-
timestamp: new Date(Date.parse(_item.created_at.replace(/( \+)/, ' UTC$1'))).getTime(),
142+
timestamp: new Date(Date.parse(_item.created_at.replace(/^\w+ (\w+) (\d+) ([\d:]+) \+0000 (\d+)$/, "$1 $2 $4 $3 UTC"))).getTime(),
143143
text: _item.text,
144144
shares: _item.retweet_count,
145145
likes: _item.favorite_count,
146146
});
147147

148-
socialObject.date_time = new Date(socialObject.timestamp);
148+
if(socialObject.timestamp) {
149+
socialObject.date_time = new Date(socialObject.timestamp);
150+
}
149151

150152
if (_item.entities && _item.entities.media && _item.entities.media.length > 0) {
151153
socialObject.source = _item.entities.media;
@@ -174,13 +176,15 @@ angular.module("jtt_aping_codebird")
174176
blog_id: _item.user.id_str,
175177
blog_link: this.getThisPlattformLink() + _item.user.screen_name + "/",
176178
intern_id: _item.id_str,
177-
timestamp: new Date(Date.parse(_item.created_at.replace(/( \+)/, ' UTC$1'))).getTime(),
179+
timestamp: new Date(Date.parse(_item.created_at.replace(/^\w+ (\w+) (\d+) ([\d:]+) \+0000 (\d+)$/, "$1 $2 $4 $3 UTC"))).getTime(),
178180
text: _item.text,
179181
shares: _item.retweet_count,
180182
likes: _item.favorite_count,
181183
});
182184

183-
imageObject.date_time = new Date(imageObject.timestamp);
185+
if(imageObject.timestamp) {
186+
imageObject.date_time = new Date(imageObject.timestamp);
187+
}
184188

185189
if (_item.entities && _item.entities.media && _item.entities.media.length > 0) {
186190

0 commit comments

Comments
 (0)