Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ npm install @bernagl/react-native-date react-native-nitro-modules
cd ios && pod install
```

**Requirements:** React Native 0.76+ (New Architecture) • iOS 13.0+ • Android API 24+
**Requirements:** React Native 0.76+ (New Architecture) • Nitro Modules 0.35.x • iOS 13.0+ • Android API 24+

## Is this library for you?

Expand Down
6 changes: 6 additions & 0 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All functions accept flexible date inputs and return timestamps (milliseconds si
type DateInput = number | string | Date;
```

::: warning v3.0 Native Requirement
v3.0 requires `react-native-nitro-modules >=0.35.0 <0.36.0`. Reinstall pods and rebuild native apps after upgrading.

See [Release Notes](https://github.com/bbernag/react-native-date/blob/main/packages/native-date/RELEASE_NOTES_v3.0.0.md) for migration steps.
:::

::: warning v2.0 Breaking Changes
- `parse()` now uses **local time** for date-only strings (was UTC)
- Getter functions now return **local time** components (was UTC)
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ import { nativeDate } from '@bernagl/react-native-date/chain';
| iOS | 13.0+ |
| Android | API 24+ (Android 7.0) |
| React Native | 0.76+ (New Architecture) |
| Nitro Modules | 0.35.x |

---

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"packages/*"
],
"scripts": {
"native-date": "yarn workspace @rn-packages/native-date",
"native-date": "yarn workspace @bernagl/react-native-date",
"prepare": "yarn native-date prepare",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
Expand Down
8 changes: 4 additions & 4 deletions packages/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PODS:
- hermes-engine (0.81.1):
- hermes-engine/Pre-built (= 0.81.1)
- hermes-engine/Pre-built (0.81.1)
- NativeDate (1.0.0):
- NativeDate (3.0.0):
- boost
- DoubleConversion
- fast_float
Expand Down Expand Up @@ -38,7 +38,7 @@ PODS:
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- NitroModules (0.31.10):
- NitroModules (0.35.7):
- boost
- DoubleConversion
- fast_float
Expand Down Expand Up @@ -2553,8 +2553,8 @@ SPEC CHECKSUMS:
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
hermes-engine: 4f8246b1f6d79f625e0d99472d1f3a71da4d28ca
NativeDate: 1750ff7f7c77731145e1ef0e166e1c3c363df987
NitroModules: 5bc319d441f4983894ea66b1d392c519536e6d23
NativeDate: 137a302e716121fa55eb344f8b35363590f71a07
NitroModules: 9ec4a2e0b9af22ba1f1f550e1dd9be94143afd18
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
RCTDeprecation: c4b9e2fd0ab200e3af72b013ed6113187c607077
RCTRequired: e97dd5dafc1db8094e63bc5031e0371f092ae92a
Expand Down
2 changes: 1 addition & 1 deletion packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"luxon": "^3.5.0",
"react": "19.1.0",
"react-native": "0.81.1",
"react-native-nitro-modules": "^0.31.10"
"react-native-nitro-modules": "0.35.7"
},
"devDependencies": {
"@babel/core": "^7.25.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/expo-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"expo-status-bar": "~3.0.9",
"react": "19.1.0",
"react-native": "0.81.5",
"react-native-nitro-modules": "^0.31.10"
"react-native-nitro-modules": "0.35.7"
},
"devDependencies": {
"@types/react": "~19.1.0",
Expand Down
14 changes: 10 additions & 4 deletions packages/native-date-examples/src/NativeTestScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ const EARLIER_TS = parse(EARLIER_DATE);
const LATER_DATE = '2024-06-20T18:00:00.000Z';
const LATER_TS = parse(LATER_DATE);

const durationIncludesUnit = (
value: string,
amount: number,
unit: 'd' | 'h'
) => value.replace(/[,\s]/g, '').startsWith(`${amount}${unit}`);

function createTestCategories(): Record<TabName, TestCategory> {
return {
Core: {
Expand Down Expand Up @@ -1313,14 +1319,14 @@ function createTestCategories(): Record<TabName, TestCategory> {
// formatDuration
{
name: 'formatDuration() 1 hour',
test: () => formatDuration(3600000).includes('1h'),
expected: 'contains "1h"',
test: () => durationIncludesUnit(formatDuration(3600000), 1, 'h'),
expected: 'starts with 1 hour unit',
getActual: () => formatDuration(3600000),
},
{
name: 'formatDuration() 1 day',
test: () => formatDuration(86400000).includes('1d'),
expected: 'contains "1d"',
test: () => durationIncludesUnit(formatDuration(86400000), 1, 'd'),
expected: 'starts with 1 day unit',
getActual: () => formatDuration(86400000),
},
// toISOString
Expand Down
22 changes: 21 additions & 1 deletion packages/native-date/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.0.0] - 2026-05-26

### Changed

- Upgrade Nitro Modules and Nitrogen generation to the 0.35 line.
- Require `react-native-nitro-modules` 0.35.x for native integration.
- Regenerate Nitro native specs with Nitrogen 0.35.7.

### Fixed

- Update Android native registration for the Nitro Modules 0.35 runtime contract.
- Relax the example app duration test assertions so native-formatted duration separators do not create false failures.

### Migration

- Upgrade consuming apps to `react-native-nitro-modules >=0.35.0 <0.36.0`.
- Reinstall iOS pods and rebuild native apps after upgrading.
- Keep the JavaScript date API unchanged from v2.x.

## [0.1.0] - 2024-XX-XX

### Added
Expand Down Expand Up @@ -39,5 +58,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Minimal bridge overhead with Nitro Modules
- Benchmark results show 2-22x improvement over date-fns/dayjs for various operations

[Unreleased]: https://github.com/bbernag/react-native-date/compare/v0.1.0...HEAD
[Unreleased]: https://github.com/bbernag/react-native-date/compare/v3.0.0...HEAD
[3.0.0]: https://github.com/bbernag/react-native-date/compare/v2.0.0...v3.0.0
[0.1.0]: https://github.com/bbernag/react-native-date/releases/tag/v0.1.0
2 changes: 1 addition & 1 deletion packages/native-date/NativeDate.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Pod::Spec.new do |s|
s.authors = package["author"]

s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => "https://github.com/bbernag/react-native-date.git", :tag => "#{s.version}" }
s.source = { :git => "https://github.com/bbernag/react-native-date.git", :tag => "v#{s.version}" }

s.source_files = [
"ios/**/*.{m,mm}",
Expand Down
3 changes: 3 additions & 0 deletions packages/native-date/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

High-performance native date library for React Native, powered by C++ and [Nitro Modules](https://nitro.margelo.com/).

> **v3.0 Native Requirement:** This release requires `react-native-nitro-modules >=0.35.0 <0.36.0`. See [RELEASE_NOTES_v3.0.0.md](./RELEASE_NOTES_v3.0.0.md) for migration steps.

> **v2.0 Breaking Changes:** `parse()` and getter functions now use local time for date-only strings (previously UTC). See [RELEASE_NOTES_v2.0.0.md](./RELEASE_NOTES_v2.0.0.md) for migration guide.

## Features
Expand All @@ -18,6 +20,7 @@ High-performance native date library for React Native, powered by C++ and [Nitro
## Requirements

- React Native 0.76+ (New Architecture required)
- Nitro Modules 0.35.x
- iOS 13.0+
- Android SDK 24+

Expand Down
75 changes: 75 additions & 0 deletions packages/native-date/RELEASE_NOTES_v3.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Release Notes v3.0.0

## Highlights

This release upgrades the native Nitro integration to the Nitro Modules 0.35 line while keeping the JavaScript date API unchanged from v2.x.

The package now builds and publishes with:

- `react-native-nitro-modules` 0.35.7 for development and example validation
- `nitrogen` 0.35.7 for generated native specs
- `react-native-nitro-modules >=0.35.0 <0.36.0` as the public peer dependency

## Breaking Changes

### Nitro Modules 0.35.x Is Required

Consumers must install a Nitro Modules 0.35 release. Older Nitro Modules 0.31.x apps are no longer compatible with this package version.

```bash
npm install @bernagl/react-native-date@3.0.0 react-native-nitro-modules@0.35.7
# or
yarn add @bernagl/react-native-date@3.0.0 react-native-nitro-modules@0.35.7
```

## Migration Guide

1. Upgrade the packages:

```bash
npm install @bernagl/react-native-date@3.0.0 react-native-nitro-modules@0.35.7
# or
yarn add @bernagl/react-native-date@3.0.0 react-native-nitro-modules@0.35.7
```

2. Reinstall iOS pods:

```bash
cd ios
pod install
```

3. Rebuild the native app:

```bash
npx react-native run-ios
npx react-native run-android
```

4. For Expo Dev Client apps, prebuild before running:

```bash
npx expo prebuild --clean
npx expo run:ios
npx expo run:android
```

Expo Go is not supported because this package includes native code.

## Compatibility Notes

- No JavaScript date API changes were introduced in v3.0.0.
- Existing v2.x parsing, formatting, timezone, locale, chain, and async APIs remain unchanged.
- The version bump is major because the native Nitro peer dependency changed.
- The peer range intentionally stops before Nitro Modules 0.36 until that line is validated.

## Validation

Release validation included:

- TypeScript check for `@bernagl/react-native-date`
- Jest suite: 923 tests passing
- iOS example build on simulator
- iOS in-app native tests: 194/194 passing
- Android example debug build on emulator
- Android in-app native tests: 194/194 passing
5 changes: 4 additions & 1 deletion packages/native-date/android/src/main/cpp/cpp-adapter.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <jni.h>
#include <fbjni/fbjni.h>
#include "rnpackages_nativedateOnLoad.hpp"

// Forward declarations for platform helpers
Expand All @@ -12,5 +13,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
LocaleHelper_setJavaVM(vm);
RelativeTimeHelper_setJavaVM(vm);

return margelo::nitro::rnpackages_nativedate::initialize(vm);
return facebook::jni::initialize(vm, []() {
margelo::nitro::rnpackages_nativedate::registerAllNatives();
});
}
6 changes: 5 additions & 1 deletion packages/native-date/nitro.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://nitro.margelo.com/nitro.schema.json",
"cxxNamespace": ["rnpackages_nativedate"],
"ios": {
"iosModuleName": "NativeDate"
Expand All @@ -9,7 +10,10 @@
},
"autolinking": {
"NativeDate": {
"cpp": "HybridNativeDate"
"all": {
"language": "c++",
"implementationClassName": "HybridNativeDate"
}
}
},
"ignorePaths": ["node_modules"]
Expand Down
10 changes: 6 additions & 4 deletions packages/native-date/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bernagl/react-native-date",
"version": "2.0.0",
"version": "3.0.0",
"description": "The fastest date library for React Native. Powered by C++ and Nitro Modules.",
"sideEffects": false,
"main": "./lib/module/index.js",
Expand All @@ -26,6 +26,8 @@
"cpp",
"nitrogen",
"nitro.json",
"CHANGELOG.md",
"RELEASE_NOTES_*.md",
"*.podspec",
"react-native.config.js",
"!ios/build",
Expand Down Expand Up @@ -112,20 +114,20 @@
"eslint-plugin-react-native": "^5.0.0",
"jest": "^30.2.0",
"lefthook": "^2.0.3",
"nitrogen": "^0.31.10",
"nitrogen": "0.35.7",
"prettier": "^2.8.8",
"react": "19.1.0",
"react-native": "0.81.1",
"react-native-builder-bob": "^0.40.16",
"react-native-nitro-modules": "^0.31.10",
"react-native-nitro-modules": "0.35.7",
"ts-jest": "^29.4.6",
"turbo": "^2.5.6",
"typescript": "^5.9.2"
},
"peerDependencies": {
"react": "*",
"react-native": "*",
"react-native-nitro-modules": "^0.31.10"
"react-native-nitro-modules": ">=0.35.0 <0.36.0"
},
"react-native-builder-bob": {
"source": "src",
Expand Down
Loading
Loading