Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ For more information about changelogs, check
[Keep a Changelog](http://keepachangelog.com) and
[Vandamme](http://tech-angels.github.io/vandamme).


## 1.0.0 - Unreleased

* [IMPROVEMENT] Return UTC time for String value of `created_time`, `backdated_time`,
`end_time`, etc from Facebook to have exact time.

## 1.0.0.beta10 - 2018/05/01

* [FEATURE] Add `:since` and `:until` option to `Page#videos` method.
Expand Down
8 changes: 5 additions & 3 deletions lib/fb/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def metric_insights(metric, period, options = {})
insights = page_insights Array(metric), options.merge(period: period)
values = insights.find{|data| data['name'] == metric}['values']
values.map do |v|
[Date.strptime(v['end_time'], '%Y-%m-%dT%H:%M:%S+0000'), v.fetch('value', 0)]
[Date.parse(v['end_time']), v.fetch('value', 0)]
end.to_h
end

Expand Down Expand Up @@ -70,10 +70,11 @@ def like_count(options = {})
# @option [Boolean] :with_metrics whether to include insights for the posts.
def posts(options = {})
@posts ||= begin
with_metrics = options.delete :with_metrics
params = posts_params.merge options
request = PaginatedRequest.new path: "/v2.9/#{@id}/posts", params: params
data = request.run.body['data']
options[:with_metrics] ? posts_with_metrics_from(data) : posts_from(data)
with_metrics ? posts_with_metrics_from(data) : posts_from(data)
end
end

Expand All @@ -95,10 +96,11 @@ def posts_with_time_range(options = {})
# @option [Boolean] :without_lifetime_metrics whether to include insights for the videos.
def videos(options = {})
@videos ||= begin
without_lifetime_metrics = options.delete :without_lifetime_metrics
params = video_params.merge options
request = PaginatedRequest.new path: "/v2.9/#{@id}/videos", params: params
data = request.run.body['data']
options[:without_lifetime_metrics] ? videos_from(data) : videos_with_metrics_from(data)
without_lifetime_metrics ? videos_from(data) : videos_with_metrics_from(data)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/fb/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class Post
def initialize(options = {})
@id = options[:id]
@url = options[:permalink_url]
@created_at = Time.strptime(options[:created_time], '%Y-%m-%dT%H:%M:%S+0000')
@created_at = Time.parse options[:created_time]
@type = options[:type]
@message = options[:message]
@length = options.fetch(:properties, []).find(-> { {'text' => 'n/a'} }) do |property|
Expand Down
4 changes: 2 additions & 2 deletions lib/fb/video.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def initialize(options = {})
@content_tags = options[:content_tags] ? Array(options[:content_tags]) : []
@ad_breaks = options[:ad_breaks] ? Array(options[:ad_breaks]) : []
@length = options[:length]
@created_at = Time.strptime(options[:created_time], '%Y-%m-%dT%H:%M:%S+0000') if options[:created_time]
@backdated_time = Time.strptime(options[:backdated_time], '%Y-%m-%dT%H:%M:%S+0000') if options[:backdated_time]
@created_at = Time.parse(options[:created_time]) if options[:created_time]
@backdated_time = Time.parse(options[:backdated_time]) if options[:backdated_time]

@total_views = options[:total_video_views]
@total_views_unique = options[:total_video_views_unique]
Expand Down