@purple-brock/time 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/lrprice79/badger-time/HEAD/assets/purple-brock-icon.png" width="140" alt="
|
|
2
|
+
<img src="https://raw.githubusercontent.com/lrprice79/badger-time/HEAD/assets/purple-brock-icon.png" width="140" alt="Purple Brock Time">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
<h1 align="center">
|
|
5
|
+
<h1 align="center">Purple Brock Time</h1>
|
|
6
6
|
|
|
7
7
|
> The date library that actually understands where your users are sett.
|
|
8
8
|
|
|
@@ -14,12 +14,12 @@ A small, fast library for working with dates and times in JavaScript and TypeScr
|
|
|
14
14
|
|
|
15
15
|
Working with dates sounds simple — until your app needs to handle users in different countries, different time zones, and different date formats. Most date libraries assume everyone works Monday to Friday, weeks start on Monday, and times are shown in 24-hour format. That's wrong for a large part of the world.
|
|
16
16
|
|
|
17
|
-
**
|
|
17
|
+
**Purple Brock Time** handles this automatically:
|
|
18
18
|
|
|
19
|
-
- **Weekends differ by country.** In Saudi Arabia, the weekend is Friday and Saturday. In Israel it is also Friday and Saturday. In most of the world it is Saturday and Sunday.
|
|
20
|
-
- **Week starts differ by country.** In the US, weeks start on Sunday. In the UK and most of Europe, they start on Monday.
|
|
21
|
-
- **Time format differs by country.** In the US, people use 12-hour clocks (3:30 PM). In Germany, 24-hour clocks (15:30).
|
|
22
|
-
- **Daylight saving time is handled correctly.** Calculating "start of today" or "days between two dates" can give wrong answers when clocks change.
|
|
19
|
+
- **Weekends differ by country.** In Saudi Arabia, the weekend is Friday and Saturday. In Israel it is also Friday and Saturday. In most of the world it is Saturday and Sunday. Purple Brock Time knows this for every locale (country/language setting) in the world.
|
|
20
|
+
- **Week starts differ by country.** In the US, weeks start on Sunday. In the UK and most of Europe, they start on Monday. Purple Brock Time picks the right one automatically.
|
|
21
|
+
- **Time format differs by country.** In the US, people use 12-hour clocks (3:30 PM). In Germany, 24-hour clocks (15:30). Purple Brock Time switches automatically based on locale.
|
|
22
|
+
- **Daylight saving time is handled correctly.** Calculating "start of today" or "days between two dates" can give wrong answers when clocks change. Purple Brock Time does this correctly.
|
|
23
23
|
|
|
24
24
|
You set your app's locale once at startup — every date operation and every formatted date in your app picks it up automatically.
|
|
25
25
|
|
|
@@ -41,7 +41,7 @@ yarn add @purple-brock/time
|
|
|
41
41
|
|
|
42
42
|
## How does it compare to other libraries?
|
|
43
43
|
|
|
44
|
-
| Feature | moment | date-fns | luxon |
|
|
44
|
+
| Feature | moment | date-fns | luxon | Purple Brock Time |
|
|
45
45
|
|---|:---:|:---:|:---:|:---:|
|
|
46
46
|
| No extra packages needed | ✗ | ✗ | ✅ | ✅ |
|
|
47
47
|
| Dates are never modified in place | ✗ | ✅ | ✅ | ✅ |
|
|
@@ -266,7 +266,7 @@ Throws an error for impossible values (e.g. month 0, hour 25), fractional values
|
|
|
266
266
|
|
|
267
267
|
### Business days
|
|
268
268
|
|
|
269
|
-
This is where
|
|
269
|
+
This is where Purple Brock Time is unique. It uses built-in browser/Node tools to know which days are weekends for every country in the world — no hard-coded rules, no extra data files.
|
|
270
270
|
|
|
271
271
|
**Weekend rules are looked up in this order:** explicit locale argument → `BadgerSettings.defaultLocale` → Saturday + Sunday.
|
|
272
272
|
|
|
@@ -299,7 +299,7 @@ No other date library does this natively. Other libraries just don't give a badg
|
|
|
299
299
|
|
|
300
300
|
Weekends are derived automatically; **public holidays are not** — no locale or
|
|
301
301
|
region string can tell you that Dec 25 is a UK bank holiday but not a Saudi one,
|
|
302
|
-
and
|
|
302
|
+
and Purple Brock Time deliberately ships **no holiday data** (that would be a country-
|
|
303
303
|
by-country calendar to maintain forever). Instead every business-day method takes
|
|
304
304
|
an optional set of holiday dates that *you* supply — typically resolved from a
|
|
305
305
|
source like [`date-holidays`](https://www.npmjs.com/package/date-holidays), keyed
|
|
@@ -534,7 +534,7 @@ nearest month (31 Jan → 1 Mar is "last month").
|
|
|
534
534
|
**Time zone default:** a `Sett` with no `timeZone` option uses `BadgerSettings.defaultTimeZone`, else
|
|
535
535
|
the **device's own zone** (it used to fall back to Europe/London).
|
|
536
536
|
|
|
537
|
-
**React Native / Hermes:** Hermes has no `Intl.Locale`.
|
|
537
|
+
**React Native / Hermes:** Hermes has no `Intl.Locale`. Purple Brock Time never needs one: the
|
|
538
538
|
default locale is the plain tag `"en-GB"`, and anything that wants week info (`isWeekend`,
|
|
539
539
|
`startOfWeek`, `getDaysOfTheWeek`, the business-day methods) or the 12/24-hour clock
|
|
540
540
|
(`formatTimeOnly`) reads it safely, falling back to **Monday-first, Saturday + Sunday weekend**
|
|
@@ -898,7 +898,7 @@ await fetch(`/api/orders?from=${from}&to=${to}`);
|
|
|
898
898
|
### Comparing dates across time zones
|
|
899
899
|
|
|
900
900
|
```ts
|
|
901
|
-
// Server returns UTC timestamps —
|
|
901
|
+
// Server returns UTC timestamps — Purple Brock Time handles them correctly
|
|
902
902
|
const serverDate = Badger("2026-06-15T22:00:00Z");
|
|
903
903
|
|
|
904
904
|
// A user in Central European Summer Time (UTC+2) sees this as midnight on Jun 16
|