A TypeScript React application that displays a random number which automatically updates daily at midnight Philippine Time (Asia/Manila).
- ✅ Timezone-Aware: Automatically syncs with Philippine Time (Asia/Manila)
- ✅ Offline-First: No external API dependencies - works completely offline
- ✅ Type-Safe: Built with TypeScript in strict mode
- ✅ Well-Tested: 25 unit tests with 100% pass rate
- ✅ Modern Stack: React 18 + Vite + Vitest
- ✅ Developer Mode: Test mode for rapid development (5-second intervals)
- Language: TypeScript (Strict Mode)
- Framework: React 18
- Build Tool: Vite 5
- Testing: Vitest + React Testing Library
- Styling: Inline styles (React)
- Node.js 16+ and npm
# Clone the repository
git clone https://github.com/YOUR_USERNAME/DayTimeTracker.git
cd DayTimeTracker
# Install dependencies
npm install
# Start development server
npm run devOpen http://localhost:5173 to view it in your browser.
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm test # Run tests in watch mode
npm run type-check # TypeScript type checkingsrc/
├── main.tsx # Application entry point
├── DayTimeTracker.tsx # Main container component
├── components/
│ ├── RandomButton.tsx # Button displaying random number
│ ├── RandomTextField.tsx # Text field showing random number
│ └── TimeInfo.tsx # Current time and next update display
├── hooks/
│ └── useDailyRandom.ts # Custom hook for random number logic
└── test/
└── setup.js # Test configuration
- Random Number Generation: Uses the current Philippine date as a seed to generate a pseudo-random number (1000-9999)
- Automatic Updates: Calculates milliseconds until midnight Philippine Time and schedules automatic updates
- Timezone Handling: Leverages browser's built-in Intl API for accurate timezone conversion
- Persistence: Same number displays all day (based on PH date seed)
Run the test suite:
npm testTest Coverage:
- 5 test suites
- 25 tests passing
- Components, hooks, and integration tests
In src/hooks/useDailyRandom.ts:
const TEST_MODE = true; // Updates every 5 secondsSet to false for production (updates at midnight PHT).
npm run buildThe optimized build will be in the dist/ directory.
- Chrome/Edge (latest)
- Firefox (latest)
- Safari (latest)
Requires browser support for:
- ES2020
- Intl API with timezone support
- React 18
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
postnodeal90 Project Link: https://github.com/postnodeal90/DayTimeTracker