diff --git a/.husky/pre-commit b/.husky/pre-commit
new file mode 100644
index 0000000..bfe23ec
--- /dev/null
+++ b/.husky/pre-commit
@@ -0,0 +1 @@
+npm run typecheck && npm run test
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ce306c2..2476f2c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+## Version 0.1.9
+
+### Fixed
+
+- fix timezone for "today's transactions"
+
## Version 0.1.8
### Changed
diff --git a/README.md b/README.md
index 9524d67..a718ef7 100644
--- a/README.md
+++ b/README.md
@@ -18,36 +18,6 @@ Want to try HabitTrove before installing? Visit the public [demo instance](https
- 🌙 Dark mode support (WIP)
- 📲 Progressive Web App (PWA) support (Planned)
-## Getting Started
-
-### Prerequisites
-
-- Node.js 20 or later
-- npm package manager
-
-### Installation
-
-1. Clone the repository:
-
-```bash
-git clone https://github.com/dohsimpson/habittrove.git
-cd habittrove
-```
-
-2. Install dependencies:
-
-```bash
-npm install --force
-```
-
-3. Start the development server:
-
-```bash
-npm run dev
-```
-
-4. Open [http://localhost:3000](http://localhost:3000) with your browser to see the application.
-
## Usage
1. **Creating Habits**: Click the "Add Habit" button to create a new habit. Set a name, description, and coin reward.
@@ -109,6 +79,73 @@ npm run docker-run
The application data will be persisted in the `data` directory in both cases.
+## Building the Project
+
+To contribute to HabitTrove, you'll need to set up a development environment. Here's how to get started:
+
+### Prerequisites
+
+- Node.js 20 or later
+- npm package manager
+- Git (for version control)
+- bun (for running tests)
+
+### Setting Up the Development Environment
+
+1. Clone the repository and navigate to the project directory:
+
+```bash
+git clone https://github.com/dohsimpson/habittrove.git
+cd habittrove
+```
+
+2. Install project dependencies:
+
+```bash
+npm install --force
+```
+
+3. Set up the development environment:
+
+```bash
+npm run setup:dev
+```
+
+4. Start the development server:
+
+```bash
+npm run dev
+```
+
+5. Open [http://localhost:3000](http://localhost:3000) in your browser to access the development version.
+
+### Running Tests
+
+Before contributing, make sure to run the test suite:
+
+```bash
+npm test
+```
+
+### Building for Production
+
+To build the project for production:
+
+```bash
+npm run build
+```
+
+This will create an optimized production build in the `.next` directory.
+
+### Code Quality Tools
+
+The project uses several tools to maintain code quality:
+
+- ESLint for linting: `npm run lint`
+- TypeScript type checking: `npm run type-check`
+
+Run these commands regularly during development to catch issues early.
+
## Contributing
Contributions are welcome! We appreciate both:
diff --git a/components/CoinsManager.tsx b/components/CoinsManager.tsx
index 31e2e89..81c9151 100644
--- a/components/CoinsManager.tsx
+++ b/components/CoinsManager.tsx
@@ -133,7 +133,7 @@ export default function CoinsManager() {
Today's Transactions
{transactions.filter(t =>
- isSameDate(getNow({}), t2d({ timestamp: t.timestamp }))
+ isSameDate(getNow({ timezone: settings.system.timezone }), t2d({ timestamp: t.timestamp, timezone: settings.system.timezone }))
).length} 📊
diff --git a/lib/utils.test.ts b/lib/utils.test.ts
index 93032bf..6e19faf 100644
--- a/lib/utils.test.ts
+++ b/lib/utils.test.ts
@@ -53,7 +53,7 @@ describe('datetime utilities', () => {
const testDateTime = DateTime.fromISO(testTimestamp);
test('t2d should convert ISO timestamp to DateTime', () => {
- const result = t2d({ timestamp: testTimestamp });
+ const result = t2d({ timestamp: testTimestamp, timezone: 'utc' });
// Normalize both timestamps to handle different UTC offset formats (Z vs +00:00)
expect(DateTime.fromISO(result.toISO()!).toMillis())
.toBe(DateTime.fromISO(testTimestamp).toMillis())
@@ -65,10 +65,10 @@ describe('datetime utilities', () => {
})
test('d2s should format DateTime for display', () => {
- const result = d2s({ dateTime: testDateTime });
+ const result = d2s({ dateTime: testDateTime, timezone: 'utc' });
expect(result).toBeString()
-
- const customFormat = d2s({ dateTime: testDateTime, format: 'yyyy-MM-dd' });
+
+ const customFormat = d2s({ dateTime: testDateTime, format: 'yyyy-MM-dd', timezone: 'utc' });
expect(customFormat).toBe('2024-01-01')
})
diff --git a/lib/utils.ts b/lib/utils.ts
index f55faca..0ffec1a 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -24,7 +24,7 @@ export function getNowInMilliseconds() {
}
// iso timestamp to datetime object, most for storage read
-export function t2d({ timestamp, timezone }: { timestamp: string; timezone?: string }) {
+export function t2d({ timestamp, timezone }: { timestamp: string; timezone: string }) {
return DateTime.fromISO(timestamp).setZone(timezone);
}
diff --git a/package-lock.json b/package-lock.json
index 4e4e532..2e9c224 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "habittrove",
- "version": "0.1.5",
+ "version": "0.1.8",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "habittrove",
- "version": "0.1.5",
+ "version": "0.1.8",
"dependencies": {
"@next/font": "^14.2.15",
"@radix-ui/react-dialog": "^1.1.4",
@@ -49,6 +49,7 @@
"eslint": "^9",
"eslint-config-next": "15.1.3",
"eslint-plugin-unused-imports": "^4.1.4",
+ "husky": "^9.1.7",
"postcss": "^8",
"raw-loader": "^4.0.2",
"tailwindcss": "^3.4.1",
@@ -4507,6 +4508,21 @@
"url": "https://opencollective.com/unified"
}
},
+ "node_modules/husky": {
+ "version": "9.1.7",
+ "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz",
+ "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==",
+ "dev": true,
+ "bin": {
+ "husky": "bin.js"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/typicode"
+ }
+ },
"node_modules/ignore": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
diff --git a/package.json b/package.json
index 8b2b332..6baed27 100644
--- a/package.json
+++ b/package.json
@@ -7,8 +7,12 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
+ "test": "bun test",
+ "typecheck": "tsc --noEmit",
"docker-build": "docker build -t habittrove .",
- "docker-run": "docker run -p 3000:3000 -v $(pwd)/data:/app/data habittrove"
+ "docker-run": "docker run -p 3000:3000 -v $(pwd)/data:/app/data habittrove",
+ "prepare": "husky",
+ "setup:dev": "if ! command -v bun > /dev/null; then echo 'Installing bun...'; curl -fsSL https://bun.sh/install | bash; fi && npm install --force && npm run typecheck && npm run lint"
},
"dependencies": {
"@next/font": "^14.2.15",
@@ -52,6 +56,7 @@
"eslint": "^9",
"eslint-config-next": "15.1.3",
"eslint-plugin-unused-imports": "^4.1.4",
+ "husky": "^9.1.7",
"postcss": "^8",
"raw-loader": "^4.0.2",
"tailwindcss": "^3.4.1",