A PostgreSQL-Typed extension to switch the timezone of a column from one to another
Install @postgresql-typed/tzswitcher
npm install --save @postgresql-typed/tzswitcher
Add the TzSwitcher extension to the core.extensions
array in your PostgreSQL-Typed configuration.
And set any options you want to use in the tzswitcher
object.
(All options are optional, and will use the default values if not set)
NOTE: You most likely want to put this extension at the start of the array, so that it is run before any other extensions.
// pgt.config.ts (or postgresql-typed.config.ts)
import { defineConfig } from "@postgresql-typed/cli/config";
import "@postgresql-typed/tzswitcher/register";
export default defineConfig({
core: {
extensions: [
"@postgresql-typed/tzswitcher",
],
},
// TzSwitcher configuration (All options are optional)
// By default, all the from/to objects are set to false (meaning they won't be switched)
tzswitcher: {
// timestamp/timestamptz/time/timetz columns
timestamp: {
from: "UTC", // The timezone that is stored in the database
to: "Asia/Seoul", // The timezone that you want to switch to locally
},
timestamptz: false, // Disable timestamptz switching
time: {
from: "UTC",
to: "Asia/Seoul",
},
timetz: false,
}
});
This package is part of the PostgreSQL-Typed ecosystem.