mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-21 06:34:30 +01:00
fix tz in today transaction on coin page (#16)
This commit is contained in:
1
.husky/pre-commit
Normal file
1
.husky/pre-commit
Normal file
@@ -0,0 +1 @@
|
|||||||
|
npm run typecheck && npm run test
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Version 0.1.9
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- fix timezone for "today's transactions"
|
||||||
|
|
||||||
## Version 0.1.8
|
## Version 0.1.8
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
97
README.md
97
README.md
@@ -18,36 +18,6 @@ Want to try HabitTrove before installing? Visit the public [demo instance](https
|
|||||||
- 🌙 Dark mode support (WIP)
|
- 🌙 Dark mode support (WIP)
|
||||||
- 📲 Progressive Web App (PWA) support (Planned)
|
- 📲 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
|
## Usage
|
||||||
|
|
||||||
1. **Creating Habits**: Click the "Add Habit" button to create a new habit. Set a name, description, and coin reward.
|
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.
|
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
|
## Contributing
|
||||||
|
|
||||||
Contributions are welcome! We appreciate both:
|
Contributions are welcome! We appreciate both:
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ export default function CoinsManager() {
|
|||||||
<div className="text-sm text-blue-800 dark:text-blue-100 mb-1">Today's Transactions</div>
|
<div className="text-sm text-blue-800 dark:text-blue-100 mb-1">Today's Transactions</div>
|
||||||
<div className="text-2xl font-bold text-blue-900 dark:text-blue-50">
|
<div className="text-2xl font-bold text-blue-900 dark:text-blue-50">
|
||||||
{transactions.filter(t =>
|
{transactions.filter(t =>
|
||||||
isSameDate(getNow({}), t2d({ timestamp: t.timestamp }))
|
isSameDate(getNow({ timezone: settings.system.timezone }), t2d({ timestamp: t.timestamp, timezone: settings.system.timezone }))
|
||||||
).length} 📊
|
).length} 📊
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ describe('datetime utilities', () => {
|
|||||||
const testDateTime = DateTime.fromISO(testTimestamp);
|
const testDateTime = DateTime.fromISO(testTimestamp);
|
||||||
|
|
||||||
test('t2d should convert ISO timestamp to DateTime', () => {
|
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)
|
// Normalize both timestamps to handle different UTC offset formats (Z vs +00:00)
|
||||||
expect(DateTime.fromISO(result.toISO()!).toMillis())
|
expect(DateTime.fromISO(result.toISO()!).toMillis())
|
||||||
.toBe(DateTime.fromISO(testTimestamp).toMillis())
|
.toBe(DateTime.fromISO(testTimestamp).toMillis())
|
||||||
@@ -65,10 +65,10 @@ describe('datetime utilities', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('d2s should format DateTime for display', () => {
|
test('d2s should format DateTime for display', () => {
|
||||||
const result = d2s({ dateTime: testDateTime });
|
const result = d2s({ dateTime: testDateTime, timezone: 'utc' });
|
||||||
expect(result).toBeString()
|
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')
|
expect(customFormat).toBe('2024-01-01')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export function getNowInMilliseconds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// iso timestamp to datetime object, most for storage read
|
// 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);
|
return DateTime.fromISO(timestamp).setZone(timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
20
package-lock.json
generated
20
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "habittrove",
|
"name": "habittrove",
|
||||||
"version": "0.1.5",
|
"version": "0.1.8",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "habittrove",
|
"name": "habittrove",
|
||||||
"version": "0.1.5",
|
"version": "0.1.8",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@next/font": "^14.2.15",
|
"@next/font": "^14.2.15",
|
||||||
"@radix-ui/react-dialog": "^1.1.4",
|
"@radix-ui/react-dialog": "^1.1.4",
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
"eslint": "^9",
|
"eslint": "^9",
|
||||||
"eslint-config-next": "15.1.3",
|
"eslint-config-next": "15.1.3",
|
||||||
"eslint-plugin-unused-imports": "^4.1.4",
|
"eslint-plugin-unused-imports": "^4.1.4",
|
||||||
|
"husky": "^9.1.7",
|
||||||
"postcss": "^8",
|
"postcss": "^8",
|
||||||
"raw-loader": "^4.0.2",
|
"raw-loader": "^4.0.2",
|
||||||
"tailwindcss": "^3.4.1",
|
"tailwindcss": "^3.4.1",
|
||||||
@@ -4507,6 +4508,21 @@
|
|||||||
"url": "https://opencollective.com/unified"
|
"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": {
|
"node_modules/ignore": {
|
||||||
"version": "5.3.2",
|
"version": "5.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
||||||
|
|||||||
@@ -7,8 +7,12 @@
|
|||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
|
"test": "bun test",
|
||||||
|
"typecheck": "tsc --noEmit",
|
||||||
"docker-build": "docker build -t habittrove .",
|
"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": {
|
"dependencies": {
|
||||||
"@next/font": "^14.2.15",
|
"@next/font": "^14.2.15",
|
||||||
@@ -52,6 +56,7 @@
|
|||||||
"eslint": "^9",
|
"eslint": "^9",
|
||||||
"eslint-config-next": "15.1.3",
|
"eslint-config-next": "15.1.3",
|
||||||
"eslint-plugin-unused-imports": "^4.1.4",
|
"eslint-plugin-unused-imports": "^4.1.4",
|
||||||
|
"husky": "^9.1.7",
|
||||||
"postcss": "^8",
|
"postcss": "^8",
|
||||||
"raw-loader": "^4.0.2",
|
"raw-loader": "^4.0.2",
|
||||||
"tailwindcss": "^3.4.1",
|
"tailwindcss": "^3.4.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user