@postgresql-typed/tzswitcher
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

@PostgreSQL-Typed/TzSwitcher

A PostgreSQL-Typed extension to switch the timezone of a column from one to another

Table of Contents Installation
Usage
Ecosystem
License

Installation

Install @postgresql-typed/tzswitcher

npm install --save @postgresql-typed/tzswitcher

Usage

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,
	}
});

Ecosystem

This package is part of the PostgreSQL-Typed ecosystem.

License

Mozilla Public License 2.0

Package Sidebar

Install

npm i @postgresql-typed/tzswitcher

Weekly Downloads

106

Version

0.3.0

License

MPL-2.0

Unpacked Size

29.2 kB

Total Files

12

Last publish

Collaborators

  • bas950