This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule :posterize_xt_date do | |
@moduledoc false | |
@behaviour Postgrex.Extension | |
import Postgrex.BinaryUtils, warn: false | |
use Postgrex.BinaryExtension, [send: "date_send"] | |
@pg_epoch :calendar.date_to_gregorian_days({ 2000, 1, 1 }) | |
@max_year 5874897 | |
@min_year -4713 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule :posterize_xt_timestamp do | |
@moduledoc false | |
@behaviour Postgrex.Extension | |
import Postgrex.BinaryUtils, warn: false | |
use Postgrex.BinaryExtension, [send: "timestamp_send"] | |
@unix_epoch :calendar.datetime_to_gregorian_seconds({{1970, 1, 1}, {0, 0, 0}}) | |
@gs_epoch :calendar.datetime_to_gregorian_seconds({{2000, 1, 1}, {0, 0, 0}}) | |
@adjustment :erlang.convert_time_unit(@gs_epoch - @unix_epoch, :seconds, :microsecond) |