diff --git a/lib/philomena/adverts/advert.ex b/lib/philomena/adverts/advert.ex
index 996a22f7..87e25379 100644
--- a/lib/philomena/adverts/advert.ex
+++ b/lib/philomena/adverts/advert.ex
@@ -27,7 +27,7 @@ defmodule Philomena.Adverts.Advert do
field :start_time, :string, virtual: true
field :finish_time, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/artist_links/artist_link.ex b/lib/philomena/artist_links/artist_link.ex
index 41e189cd..b8878951 100644
--- a/lib/philomena/artist_links/artist_link.ex
+++ b/lib/philomena/artist_links/artist_link.ex
@@ -20,7 +20,7 @@ defmodule Philomena.ArtistLinks.ArtistLink do
field :next_check_at, :utc_datetime
field :contacted_at, :utc_datetime
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/badges/award.ex b/lib/philomena/badges/award.ex
index 72691d32..0ee8da28 100644
--- a/lib/philomena/badges/award.ex
+++ b/lib/philomena/badges/award.ex
@@ -15,7 +15,7 @@ defmodule Philomena.Badges.Award do
field :reason, :string
field :badge_name, :string
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/badges/badge.ex b/lib/philomena/badges/badge.ex
index 9682a638..d7a232aa 100644
--- a/lib/philomena/badges/badge.ex
+++ b/lib/philomena/badges/badge.ex
@@ -13,7 +13,7 @@ defmodule Philomena.Badges.Badge do
field :removed_image, :string, virtual: true
field :image_mime_type, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/bans/fingerprint.ex b/lib/philomena/bans/fingerprint.ex
index 2547e0c0..bf04f2bd 100644
--- a/lib/philomena/bans/fingerprint.ex
+++ b/lib/philomena/bans/fingerprint.ex
@@ -18,7 +18,7 @@ defmodule Philomena.Bans.Fingerprint do
field :until, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/bans/subnet.ex b/lib/philomena/bans/subnet.ex
index 8a97fc50..84682593 100644
--- a/lib/philomena/bans/subnet.ex
+++ b/lib/philomena/bans/subnet.ex
@@ -18,7 +18,7 @@ defmodule Philomena.Bans.Subnet do
field :until, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/bans/user.ex b/lib/philomena/bans/user.ex
index 43e3ae96..93d0745d 100644
--- a/lib/philomena/bans/user.ex
+++ b/lib/philomena/bans/user.ex
@@ -21,7 +21,7 @@ defmodule Philomena.Bans.User do
field :username, :string, virtual: true
field :until, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/channels/channel.ex b/lib/philomena/channels/channel.ex
index 0eb163cd..1ace95a1 100644
--- a/lib/philomena/channels/channel.ex
+++ b/lib/philomena/channels/channel.ex
@@ -32,7 +32,7 @@ defmodule Philomena.Channels.Channel do
field :remote_stream_id, :integer
field :thumbnail_url, :string, default: ""
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/comments/comment.ex b/lib/philomena/comments/comment.ex
index 7852a87d..180aaaaa 100644
--- a/lib/philomena/comments/comment.ex
+++ b/lib/philomena/comments/comment.ex
@@ -23,7 +23,7 @@ defmodule Philomena.Comments.Comment do
field :destroyed_content, :boolean, default: false
field :name_at_post_time, :string
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/commissions/commission.ex b/lib/philomena/commissions/commission.ex
index e3a9262a..18cb7b7b 100644
--- a/lib/philomena/commissions/commission.ex
+++ b/lib/philomena/commissions/commission.ex
@@ -19,7 +19,7 @@ defmodule Philomena.Commissions.Commission do
field :will_not_create, :string
field :commission_items_count, :integer, default: 0
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/commissions/item.ex b/lib/philomena/commissions/item.ex
index 220fc11e..5b53301e 100644
--- a/lib/philomena/commissions/item.ex
+++ b/lib/philomena/commissions/item.ex
@@ -14,7 +14,7 @@ defmodule Philomena.Commissions.Item do
field :base_price, :decimal
field :add_ons, :string
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/conversations/conversation.ex b/lib/philomena/conversations/conversation.ex
index bb3625b8..10b2540b 100644
--- a/lib/philomena/conversations/conversation.ex
+++ b/lib/philomena/conversations/conversation.ex
@@ -22,7 +22,7 @@ defmodule Philomena.Conversations.Conversation do
field :last_message_at, :utc_datetime
field :recipient, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/conversations/message.ex b/lib/philomena/conversations/message.ex
index 80ac7487..f1dc1129 100644
--- a/lib/philomena/conversations/message.ex
+++ b/lib/philomena/conversations/message.ex
@@ -11,7 +11,7 @@ defmodule Philomena.Conversations.Message do
field :body, :string
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/dnp_entries/dnp_entry.ex b/lib/philomena/dnp_entries/dnp_entry.ex
index a178cdcf..e59ab21e 100644
--- a/lib/philomena/dnp_entries/dnp_entry.ex
+++ b/lib/philomena/dnp_entries/dnp_entry.ex
@@ -18,7 +18,7 @@ defmodule Philomena.DnpEntries.DnpEntry do
field :instructions, :string, default: ""
field :feedback, :string, default: ""
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/donations/donation.ex b/lib/philomena/donations/donation.ex
index 2191d0bd..067377fe 100644
--- a/lib/philomena/donations/donation.ex
+++ b/lib/philomena/donations/donation.ex
@@ -14,7 +14,7 @@ defmodule Philomena.Donations.Donation do
field :receipt_id, :string
field :note, :string
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/duplicate_reports/duplicate_report.ex b/lib/philomena/duplicate_reports/duplicate_report.ex
index d25b1cbe..0b0b07d3 100644
--- a/lib/philomena/duplicate_reports/duplicate_report.ex
+++ b/lib/philomena/duplicate_reports/duplicate_report.ex
@@ -14,7 +14,7 @@ defmodule Philomena.DuplicateReports.DuplicateReport do
field :reason, :string
field :state, :string, default: "open"
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/filters/filter.ex b/lib/philomena/filters/filter.ex
index 1ef4dd22..ea862b2b 100644
--- a/lib/philomena/filters/filter.ex
+++ b/lib/philomena/filters/filter.ex
@@ -23,7 +23,7 @@ defmodule Philomena.Filters.Filter do
field :spoilered_tag_list, :string, virtual: true
field :hidden_tag_list, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/forums/forum.ex b/lib/philomena/forums/forum.ex
index e70327d8..94e30b68 100644
--- a/lib/philomena/forums/forum.ex
+++ b/lib/philomena/forums/forum.ex
@@ -19,7 +19,7 @@ defmodule Philomena.Forums.Forum do
field :topic_count, :integer, default: 0
field :post_count, :integer, default: 0
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/galleries/gallery.ex b/lib/philomena/galleries/gallery.ex
index 41c02609..9be09592 100644
--- a/lib/philomena/galleries/gallery.ex
+++ b/lib/philomena/galleries/gallery.ex
@@ -20,7 +20,7 @@ defmodule Philomena.Galleries.Gallery do
field :image_count, :integer
field :order_position_asc, :boolean
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/image_features/image_feature.ex b/lib/philomena/image_features/image_feature.ex
index 030a0b6d..4411391a 100644
--- a/lib/philomena/image_features/image_feature.ex
+++ b/lib/philomena/image_features/image_feature.ex
@@ -11,7 +11,7 @@ defmodule Philomena.ImageFeatures.ImageFeature do
belongs_to :image, Image
belongs_to :user, User
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/images.ex b/lib/philomena/images.ex
index c3b1c343..074e9862 100644
--- a/lib/philomena/images.ex
+++ b/lib/philomena/images.ex
@@ -319,7 +319,7 @@ defmodule Philomena.Images do
end
defp tag_change_attributes(attribution, image, tag, added, user) do
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
user_id =
case user do
@@ -482,7 +482,7 @@ defmodule Philomena.Images do
defp update_first_seen_at(image, time_1, time_2) do
min_time =
- case NaiveDateTime.compare(time_1, time_2) do
+ case DateTime.compare(time_1, time_2) do
:gt -> time_2
_ -> time_1
end
@@ -551,7 +551,7 @@ defmodule Philomena.Images do
|> where([t], t.image_id in ^image_ids and t.tag_id in ^removed_tags)
|> select([t], [t.image_id, t.tag_id])
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
tag_change_attributes = Map.merge(tag_change_attributes, %{created_at: now, updated_at: now})
tag_attributes = %{name: "", slug: "", created_at: now, updated_at: now}
diff --git a/lib/philomena/images/image.ex b/lib/philomena/images/image.ex
index d1293c24..f1c416c5 100644
--- a/lib/philomena/images/image.ex
+++ b/lib/philomena/images/image.ex
@@ -75,7 +75,7 @@ defmodule Philomena.Images.Image do
field :tag_editing_allowed, :boolean, default: true
field :description_editing_allowed, :boolean, default: true
field :commenting_allowed, :boolean, default: true
- field :first_seen_at, :naive_datetime
+ field :first_seen_at, :utc_datetime
field :destroyed_content, :boolean
field :hidden_image_key, :string
field :scratchpad, :string
@@ -92,7 +92,7 @@ defmodule Philomena.Images.Image do
field :uploaded_image, :string, virtual: true
field :removed_image, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
def interaction_data(image) do
@@ -112,7 +112,7 @@ defmodule Philomena.Images.Image do
end
def creation_changeset(image, attrs, attribution) do
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
image
|> cast(attrs, [:anonymous, :source_url, :description])
diff --git a/lib/philomena/interactions.ex b/lib/philomena/interactions.ex
index c4dc0f0d..5ed5c8f2 100644
--- a/lib/philomena/interactions.ex
+++ b/lib/philomena/interactions.ex
@@ -72,7 +72,7 @@ defmodule Philomena.Interactions do
end
def migrate_interactions(source, target) do
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
source = Repo.preload(source, [:hiders, :favers, :upvoters, :downvoters])
new_hides = Enum.map(source.hiders, &%{image_id: target.id, user_id: &1.id, created_at: now})
diff --git a/lib/philomena/mod_notes/mod_note.ex b/lib/philomena/mod_notes/mod_note.ex
index 30c468d4..8344b7ec 100644
--- a/lib/philomena/mod_notes/mod_note.ex
+++ b/lib/philomena/mod_notes/mod_note.ex
@@ -15,7 +15,7 @@ defmodule Philomena.ModNotes.ModNote do
field :notable, :any, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/notifications/notification.ex b/lib/philomena/notifications/notification.ex
index 68805097..72951bbe 100644
--- a/lib/philomena/notifications/notification.ex
+++ b/lib/philomena/notifications/notification.ex
@@ -14,7 +14,7 @@ defmodule Philomena.Notifications.Notification do
field :actor, :any, virtual: true
field :actor_child, :any, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/poll_votes.ex b/lib/philomena/poll_votes.ex
index d18979bc..910741c1 100644
--- a/lib/philomena/poll_votes.ex
+++ b/lib/philomena/poll_votes.ex
@@ -41,7 +41,7 @@ defmodule Philomena.PollVotes do
"""
def create_poll_votes(user, poll, attrs) do
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
poll_votes = filter_options(user, poll, now, attrs)
Multi.new()
diff --git a/lib/philomena/polls/poll.ex b/lib/philomena/polls/poll.ex
index cb320431..264e96bb 100644
--- a/lib/philomena/polls/poll.ex
+++ b/lib/philomena/polls/poll.ex
@@ -20,7 +20,7 @@ defmodule Philomena.Polls.Poll do
field :deletion_reason, :string, default: ""
field :until, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/posts/post.ex b/lib/philomena/posts/post.ex
index 77ebbac2..b3c3c42f 100644
--- a/lib/philomena/posts/post.ex
+++ b/lib/philomena/posts/post.ex
@@ -24,7 +24,7 @@ defmodule Philomena.Posts.Post do
field :destroyed_content, :boolean, default: false
field :name_at_post_time, :string
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/reports/report.ex b/lib/philomena/reports/report.ex
index 4eaf1854..8f8de00b 100644
--- a/lib/philomena/reports/report.ex
+++ b/lib/philomena/reports/report.ex
@@ -23,7 +23,7 @@ defmodule Philomena.Reports.Report do
field :reportable, :any, virtual: true
field :category, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/roles/role.ex b/lib/philomena/roles/role.ex
index cdb0e8ef..359c90b1 100644
--- a/lib/philomena/roles/role.ex
+++ b/lib/philomena/roles/role.ex
@@ -9,7 +9,7 @@ defmodule Philomena.Roles.Role do
field :resource_id, :integer
field :resource_type, :string
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/site_notices/site_notice.ex b/lib/philomena/site_notices/site_notice.ex
index 2accb713..929f8f3c 100644
--- a/lib/philomena/site_notices/site_notice.ex
+++ b/lib/philomena/site_notices/site_notice.ex
@@ -19,7 +19,7 @@ defmodule Philomena.SiteNotices.SiteNotice do
field :start_time, :string, virtual: true
field :finish_time, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/source_changes/source_change.ex b/lib/philomena/source_changes/source_change.ex
index e9c97990..6d6840bf 100644
--- a/lib/philomena/source_changes/source_change.ex
+++ b/lib/philomena/source_changes/source_change.ex
@@ -15,7 +15,7 @@ defmodule Philomena.SourceChanges.SourceChange do
field :source_url, :string, source: :new_value
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/static_pages/static_page.ex b/lib/philomena/static_pages/static_page.ex
index d107d52c..bf883076 100644
--- a/lib/philomena/static_pages/static_page.ex
+++ b/lib/philomena/static_pages/static_page.ex
@@ -9,7 +9,7 @@ defmodule Philomena.StaticPages.StaticPage do
field :slug, :string
field :body, :string
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/static_pages/version.ex b/lib/philomena/static_pages/version.ex
index 172d0750..49ed3860 100644
--- a/lib/philomena/static_pages/version.ex
+++ b/lib/philomena/static_pages/version.ex
@@ -15,7 +15,7 @@ defmodule Philomena.StaticPages.Version do
field :difference, :any, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/tag_changes.ex b/lib/philomena/tag_changes.ex
index 0f7d2a00..8e3e1cef 100644
--- a/lib/philomena/tag_changes.ex
+++ b/lib/philomena/tag_changes.ex
@@ -14,7 +14,7 @@ defmodule Philomena.TagChanges do
# TODO: this is substantially similar to Images.batch_update/4.
# Perhaps it should be extracted.
def mass_revert(ids, attributes) do
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
tag_change_attributes = Map.merge(attributes, %{created_at: now, updated_at: now})
tag_attributes = %{name: "", slug: "", created_at: now, updated_at: now}
diff --git a/lib/philomena/tag_changes/tag_change.ex b/lib/philomena/tag_changes/tag_change.ex
index 20be3ba4..3bc9eb10 100644
--- a/lib/philomena/tag_changes/tag_change.ex
+++ b/lib/philomena/tag_changes/tag_change.ex
@@ -14,7 +14,7 @@ defmodule Philomena.TagChanges.TagChange do
field :added, :boolean
field :tag_name_cache, :string, default: ""
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/tags/tag.ex b/lib/philomena/tags/tag.ex
index 6cd3b108..2713a392 100644
--- a/lib/philomena/tags/tag.ex
+++ b/lib/philomena/tags/tag.ex
@@ -90,7 +90,7 @@ defmodule Philomena.Tags.Tag do
field :implied_tag_list, :string, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/topics/topic.ex b/lib/philomena/topics/topic.ex
index 0434f1bf..efc49ce4 100644
--- a/lib/philomena/topics/topic.ex
+++ b/lib/philomena/topics/topic.ex
@@ -32,7 +32,7 @@ defmodule Philomena.Topics.Topic do
field :anonymous, :boolean, default: false
field :hidden_from_users, :boolean, default: false
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/user_fingerprints/user_fingerprint.ex b/lib/philomena/user_fingerprints/user_fingerprint.ex
index d9810da8..6f707585 100644
--- a/lib/philomena/user_fingerprints/user_fingerprint.ex
+++ b/lib/philomena/user_fingerprints/user_fingerprint.ex
@@ -10,7 +10,7 @@ defmodule Philomena.UserFingerprints.UserFingerprint do
field :fingerprint, :string
field :uses, :integer, default: 0
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/user_ips/user_ip.ex b/lib/philomena/user_ips/user_ip.ex
index 6885cd63..8a0b8106 100644
--- a/lib/philomena/user_ips/user_ip.ex
+++ b/lib/philomena/user_ips/user_ip.ex
@@ -10,7 +10,7 @@ defmodule Philomena.UserIps.UserIp do
field :ip, EctoNetwork.INET
field :uses, :integer, default: 0
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/user_name_changes/user_name_change.ex b/lib/philomena/user_name_changes/user_name_change.ex
index 824533e6..f4434a8e 100644
--- a/lib/philomena/user_name_changes/user_name_change.ex
+++ b/lib/philomena/user_name_changes/user_name_change.ex
@@ -8,7 +8,7 @@ defmodule Philomena.UserNameChanges.UserNameChange do
belongs_to :user, User
field :name, :string
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/user_whitelists/user_whitelist.ex b/lib/philomena/user_whitelists/user_whitelist.ex
index e6e1bd25..7bee5b36 100644
--- a/lib/philomena/user_whitelists/user_whitelist.ex
+++ b/lib/philomena/user_whitelists/user_whitelist.ex
@@ -8,7 +8,7 @@ defmodule Philomena.UserWhitelists.UserWhitelist do
belongs_to :user, User
field :reason, :string
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc false
diff --git a/lib/philomena/users/ability.ex b/lib/philomena/users/ability.ex
index e03612b1..1789c974 100644
--- a/lib/philomena/users/ability.ex
+++ b/lib/philomena/users/ability.ex
@@ -321,8 +321,8 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do
# Edit their username
def can?(%User{id: id}, :change_username, %User{id: id} = user) do
- time_ago = NaiveDateTime.utc_now() |> NaiveDateTime.add(-1 * 60 * 60 * 24 * 90)
- NaiveDateTime.diff(user.last_renamed_at, time_ago) < 0
+ time_ago = DateTime.utc_now() |> DateTime.add(-1 * 60 * 60 * 24 * 90)
+ DateTime.diff(user.last_renamed_at, time_ago) < 0
end
# View conversations they are involved in
diff --git a/lib/philomena/users/user.ex b/lib/philomena/users/user.ex
index 15782d23..d1ac7834 100644
--- a/lib/philomena/users/user.ex
+++ b/lib/philomena/users/user.ex
@@ -48,12 +48,12 @@ defmodule Philomena.Users.User do
field :password, :string, virtual: true
field :encrypted_password, :string
field :hashed_password, :string, source: :encrypted_password
- field :confirmed_at, :naive_datetime
+ field :confirmed_at, :utc_datetime
field :otp_required_for_login, :boolean
field :authentication_token, :string
field :failed_attempts, :integer
# field :unlock_token, :string
- field :locked_at, :naive_datetime
+ field :locked_at, :utc_datetime
field :encrypted_otp_secret, :string
field :encrypted_otp_secret_iv, :string
field :encrypted_otp_secret_salt, :string
@@ -111,9 +111,9 @@ defmodule Philomena.Users.User do
field :watched_tag_list, :string, virtual: true
# Other stuff
- field :last_donation_at, :naive_datetime
- field :last_renamed_at, :naive_datetime
- field :deleted_at, :naive_datetime
+ field :last_donation_at, :utc_datetime
+ field :last_renamed_at, :utc_datetime
+ field :deleted_at, :utc_datetime
field :scratchpad, :string
field :secondary_role, :string
field :hide_default_role, :boolean, default: false
@@ -130,7 +130,7 @@ defmodule Philomena.Users.User do
# For mod stuff
field :role_map, :any, virtual: true
- timestamps(inserted_at: :created_at)
+ timestamps(inserted_at: :created_at, type: :utc_datetime)
end
@doc """
@@ -212,7 +212,7 @@ defmodule Philomena.Users.User do
Confirms the account by setting `confirmed_at`.
"""
def confirm_changeset(user) do
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
change(user, confirmed_at: now)
end
@@ -256,7 +256,7 @@ defmodule Philomena.Users.User do
end
def lock_changeset(user) do
- locked_at = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ locked_at = DateTime.utc_now() |> DateTime.truncate(:second)
change(user, locked_at: locked_at)
end
@@ -353,7 +353,7 @@ defmodule Philomena.Users.User do
end
def name_changeset(user, attrs) do
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
user
|> cast(attrs, [:name])
@@ -403,7 +403,7 @@ defmodule Philomena.Users.User do
end
def deactivate_changeset(user, moderator) do
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
change(user, deleted_at: now, deleted_by_user_id: moderator.id)
end
diff --git a/lib/philomena_web/advert_updater.ex b/lib/philomena_web/advert_updater.ex
index b3941148..02846f9e 100644
--- a/lib/philomena_web/advert_updater.ex
+++ b/lib/philomena_web/advert_updater.ex
@@ -28,7 +28,7 @@ defmodule PhilomenaWeb.AdvertUpdater do
# Read impression counts from mailbox
{impressions, clicks} = receive_all()
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
# Create insert statements for Ecto
impressions = Enum.map(impressions, &impressions_insert_all(&1, now))
diff --git a/lib/philomena_web/stats_updater.ex b/lib/philomena_web/stats_updater.ex
index e4bd4e17..f83f7559 100644
--- a/lib/philomena_web/stats_updater.ex
+++ b/lib/philomena_web/stats_updater.ex
@@ -46,7 +46,7 @@ defmodule PhilomenaWeb.StatsUpdater do
images_in_galleries: images_in_galleries
)
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
static_page = %{
title: "Statistics",
@@ -139,7 +139,7 @@ defmodule PhilomenaWeb.StatsUpdater do
response_time =
closed_reports
- |> Enum.reduce(0, &(&2 + NaiveDateTime.diff(&1.updated_at, &1.created_at, :second)))
+ |> Enum.reduce(0, &(&2 + DateTime.diff(&1.updated_at, &1.created_at, :second)))
|> Kernel./(safe_length(closed_reports) * 3600)
|> trunc()
diff --git a/lib/philomena_web/templates/api/rss/watched/index.html.eex b/lib/philomena_web/templates/api/rss/watched/index.html.eex
index 708cb6cc..e96caa93 100644
--- a/lib/philomena_web/templates/api/rss/watched/index.html.eex
+++ b/lib/philomena_web/templates/api/rss/watched/index.html.eex
@@ -17,7 +17,7 @@
]]>
- <%= NaiveDateTime.to_iso8601(image.created_at) %>
+ <%= DateTime.to_iso8601(image.created_at) %>
<%= Routes.image_url(@conn, :show, image) %>
<%= Routes.image_url(@conn, :show, image) %>
diff --git a/lib/philomena_web/user_auth.ex b/lib/philomena_web/user_auth.ex
index deea0dd9..84b79a70 100644
--- a/lib/philomena_web/user_auth.ex
+++ b/lib/philomena_web/user_auth.ex
@@ -208,7 +208,7 @@ defmodule PhilomenaWeb.UserAuth do
defp signed_in_path(_conn), do: "/"
defp update_usages(conn, user) do
- now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
+ now = DateTime.utc_now() |> DateTime.truncate(:second)
conn = fetch_cookies(conn)
UserIpUpdater.cast(user.id, conn.remote_ip, now)
diff --git a/lib/philomena_web/views/app_view.ex b/lib/philomena_web/views/app_view.ex
index afe88721..caabfa62 100644
--- a/lib/philomena_web/views/app_view.ex
+++ b/lib/philomena_web/views/app_view.ex
@@ -31,10 +31,9 @@ defmodule PhilomenaWeb.AppView do
}
def pretty_time(time) do
- now = NaiveDateTime.utc_now()
- seconds = NaiveDateTime.diff(now, time, :second)
+ now = DateTime.utc_now()
+ seconds = DateTime.diff(now, time, :second)
relation = if seconds < 0, do: "from now", else: "ago"
- time = time |> DateTime.from_naive!("Etc/UTC")
words = distance_of_time_in_words(now, time)
@@ -45,7 +44,7 @@ defmodule PhilomenaWeb.AppView do
end
def distance_of_time_in_words(time_2, time_1) do
- seconds = abs(NaiveDateTime.diff(time_2, time_1, :second))
+ seconds = abs(DateTime.diff(time_2, time_1, :second))
minutes = div(seconds, 60)
hours = div(minutes, 60)
days = div(hours, 24)
diff --git a/lib/philomena_web/views/ban_view.ex b/lib/philomena_web/views/ban_view.ex
index 3e821604..e69f42b0 100644
--- a/lib/philomena_web/views/ban_view.ex
+++ b/lib/philomena_web/views/ban_view.ex
@@ -2,6 +2,6 @@ defmodule PhilomenaWeb.BanView do
use PhilomenaWeb, :view
def active?(ban) do
- ban.enabled and NaiveDateTime.diff(ban.valid_until, NaiveDateTime.utc_now()) > 0
+ ban.enabled and DateTime.diff(ban.valid_until, DateTime.utc_now()) > 0
end
end
diff --git a/lib/philomena_web/views/image_view.ex b/lib/philomena_web/views/image_view.ex
index ce65dc8c..4fe58083 100644
--- a/lib/philomena_web/views/image_view.ex
+++ b/lib/philomena_web/views/image_view.ex
@@ -124,8 +124,6 @@ defmodule PhilomenaWeb.ImageView do
end
def image_container_data(conn, image, size) do
- time = DateTime.from_naive!(image.created_at, "Etc/UTC")
-
[
image_id: image.id,
image_tags: Jason.encode!(Enum.map(image.tags, & &1.id)),
@@ -137,7 +135,7 @@ defmodule PhilomenaWeb.ImageView do
upvotes: image.upvotes_count,
downvotes: image.downvotes_count,
comment_count: image.comments_count,
- created_at: DateTime.to_iso8601(time),
+ created_at: DateTime.to_iso8601(image.created_at),
source_url: image.source_url,
uris: Jason.encode!(thumb_urls(image, can?(conn, :show, image))),
width: image.image_width,
diff --git a/lib/philomena_web/views/profile/alias_view.ex b/lib/philomena_web/views/profile/alias_view.ex
index fc884c86..301648af 100644
--- a/lib/philomena_web/views/profile/alias_view.ex
+++ b/lib/philomena_web/views/profile/alias_view.ex
@@ -17,8 +17,8 @@ defmodule PhilomenaWeb.Profile.AliasView do
def previously_banned?(_user), do: true
defp younger_than_time_offset?(%{created_at: created_at}, time_offset) do
- time_ago = NaiveDateTime.utc_now() |> NaiveDateTime.add(-time_offset, :second)
+ time_ago = DateTime.utc_now() |> DateTime.add(-time_offset, :second)
- NaiveDateTime.diff(created_at, time_ago) >= 0
+ DateTime.diff(created_at, time_ago) >= 0
end
end