npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@huluwz/pg-ethiopian-calendar

v1.1.1

Published

Ethiopian calendar functions for PostgreSQL - works with Prisma, Drizzle, TypeORM

Readme

@huluwz/pg-ethiopian-calendar

Ethiopian calendar functions for PostgreSQL. Works on any PostgreSQL including managed services (Neon, Supabase, Railway, AWS RDS).

npm License

Install

npm install @huluwz/pg-ethiopian-calendar

Quick Start

# Generate migration (auto-detects ORM)
npx ethiopian-calendar init

# Or specify ORM
npx ethiopian-calendar init prisma
npx ethiopian-calendar init drizzle
npx ethiopian-calendar init typeorm

Then run your ORM's migration command.

SQL Functions

-- Current Ethiopian date (two ways)
SELECT to_ethiopian_date();                         -- '2018-04-23'
SELECT to_ethiopian_date(NOW());                    -- same

-- Specific date
SELECT to_ethiopian_date('2024-01-01'::timestamp);  -- '2016-04-23'

-- Ethiopian → Gregorian
SELECT from_ethiopian_date('2016-04-23');           -- '2024-01-01 00:00:00'

-- Current Ethiopian timestamp (with time)
SELECT to_ethiopian_timestamp();                    -- '2018-04-23 14:30:00'

-- Check version
SELECT ethiopian_calendar_version();                -- '1.1.0'

Generated Columns (Timestamp)

Use to_ethiopian_timestamp() for DateTime/Timestamp columns:

CREATE TABLE orders (
  id SERIAL PRIMARY KEY,
  created_at TIMESTAMP DEFAULT NOW(),
  created_at_ethiopian TIMESTAMP GENERATED ALWAYS AS 
    (to_ethiopian_timestamp(created_at)) STORED
);

For text format, use to_ethiopian_date():

CREATE TABLE events (
  id SERIAL PRIMARY KEY,
  event_date TIMESTAMP NOT NULL,
  event_date_ethiopian VARCHAR(10) GENERATED ALWAYS AS 
    (to_ethiopian_date(event_date)) STORED
);

With Prisma

Schema

model Order {
  id                 Int       @id @default(autoincrement())
  createdAt          DateTime  @default(now()) @map("created_at")
  createdAtEthiopian DateTime? @map("created_at_ethiopian")  // Generated column

  @@map("orders")
}

⚠️ Important: Migration Workflow

Prisma doesn't natively support GENERATED ALWAYS AS columns. You must create migrations manually:

# ❌ DON'T do this - Prisma will generate wrong SQL
npx prisma migrate dev

# ✅ DO this instead - create empty migration, then edit
npx prisma migrate dev --create-only --name add_orders_table

Then manually edit migration.sql:

CREATE TABLE "orders" (
    "id" SERIAL PRIMARY KEY,
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "created_at_ethiopian" TIMESTAMP(3) GENERATED ALWAYS AS 
        (to_ethiopian_timestamp(created_at)) STORED
);

Finally apply:

npx prisma migrate deploy

Usage

const order = await prisma.order.create({
  data: { name: 'Test' }
});
console.log(order.createdAtEthiopian); // auto-populated DateTime!

With Drizzle

Drizzle has native support for generated columns:

import { sql } from 'drizzle-orm';

export const orders = pgTable('orders', {
  id: serial('id').primaryKey(),
  createdAt: timestamp('created_at').defaultNow(),
  createdAtEthiopian: timestamp('created_at_ethiopian')
    .generatedAlwaysAs(sql`to_ethiopian_timestamp(created_at)`),
});

With TypeORM

Use raw SQL in migrations:

export class AddEthiopianCalendar1234567890 implements MigrationInterface {
  async up(queryRunner: QueryRunner): Promise<void> {
    // First, run the ethiopian calendar SQL from the package
    await queryRunner.query(`/* ethiopian calendar functions */`);
    
    // Then create table with generated column
    await queryRunner.query(`
      CREATE TABLE "orders" (
        "id" SERIAL PRIMARY KEY,
        "created_at" TIMESTAMP DEFAULT NOW(),
        "created_at_ethiopian" TIMESTAMP GENERATED ALWAYS AS 
          (to_ethiopian_timestamp(created_at)) STORED
      )
    `);
  }
}

API

import { getSql, VERSION, detectOrm } from '@huluwz/pg-ethiopian-calendar';

getSql();        // Full SQL content
detectOrm();     // Auto-detect installed ORM
VERSION;         // '1.1.0'

Supported ORMs

  • Prisma
  • Drizzle
  • TypeORM
  • Raw SQL

Links

License

PostgreSQL License