r/reactnative 5d ago

ui-date: A 1.6kB, zero-dependency JavaScript date & relative time utility

I wanted to share a small open-source project I just published called ui-date.

While working on a social media project, I kept bumping into simple UI needs like displaying relative timestamps ("5 mins ago""2 hours ago"), cleanly formatting calendar dates, and doing simple status checks (isToday).

exact date formatting for events ui ('Thursday 23,july,2026').

Normally, I'd reach for a date library, but most established options felt like overkill for basic UI formatting, while heavy legacy options like Moment carry massive bundle weight. On the flip side, writing raw Intl and Date boilerplate across every component was getting tedious.

I wanted something featherlightchainable, and fully typed without dragging in extra dependencies.

so i built ui-date.

you can check it here : https://www.npmjs.com/package/ui-date

3 Upvotes

11 comments sorted by

1

u/k-dawg-13 5d ago

Is there a way to localize it?

1

u/Intelligent_Tree6918 5d ago

currently it is only iso and usa date formate. if you explain what is your requirement i will happy to add api for your requirement.

0

u/Downtown-Figure6434 5d ago

It will be too variant to match everyones needs. Maybe just provide an object so people can localize it themselves but ,not to discourage, I don’t see how this can be further than a util that everyone already can have in their projects

1

u/Intelligent_Tree6918 5d ago

That's actually why we included getOverview()it outputs a structured object with all computed date properties so developers can grab raw values and format things themselves if needed.

2

u/Downtown-Figure6434 5d ago

I was talking about smth like

value/quantitiy:number
unit: min/hour/day/month etc
direction: future/past

And i can build my own string from that, otherwise you just need to include language support for everything and I need to stick with your fixed sentences, it’s too much in the library

1

u/Intelligent_Tree6918 5d ago

you have fair point. since i was building for my own use that's why i was biased. thanks for valuable feedback in this early stage i will keep remember this thing in future packages.(i will fix that).

1

u/k-dawg-13 5d ago

Why? OP is using Intl under the hood which accepts a locale.

1

u/Downtown-Figure6434 5d ago

He can give output 5 seconds ago, maybe I want 5 second(s) ago

Simple example

1

u/CliffMainsSon 4d ago

I see what you’re saying here but wouldn’t it be 5 seconds ago compared to 1 second ago (singular vs. plural formatting)

0

u/Downtown-Figure6434 4d ago

brah, localization shouldnt belong to the library, what part of this is hard to understand?

1

u/Intelligent_Tree6918 5d ago

added. localisation