A robust Node.js module for converting times between airport timezones using IATA codes. Features include UTC to local time conversion, local to UTC conversion, timezone offset calculations, and direct conversions between different airport timezones. Buil
npm install iata-tz
Website |
Getting Started |
Documentation |
API Reference |
Contributing
iata-tz is a robust Node.js module for converting times between airport timezones using IATA codes. It provides accurate conversions between UTC and local airport times, handles daylight saving time (DST) automatically, and supports all major airports worldwide.
``bash`
npm install iata-tz
- ✅ Convert local airport time to UTC
- ✅ Convert UTC to local airport time
- ✅ Convert times between different airport timezones
- ✅ Get timezone offset information for airports
- ✅ Automatic handling of Daylight Saving Time (DST)
- ✅ Supports all major airports worldwide
`javascript
const { convertToUTC, convertFromUTC, convertBetweenTimezones, getTimezoneOffset } = require('iata-tz');
// Convert local time to UTC
const utcTime = convertToUTC('JFK', '2024-01-29 14:30:00');
console.log(utcTime); // '2024-01-29 19:30:00'
// Convert UTC to local time
const localTime = convertFromUTC('LAX', '2024-01-29 19:30:00');
console.log(localTime); // '2024-01-29 11:30:00'
// Convert time between two airports
const convertedTime = convertBetweenTimezones(
'JFK', // source airport
'LAX', // target airport
'2024-01-29 14:30:00' // time in JFK
);
console.log(convertedTime); // '2024-01-29 11:30:00'
// Get timezone information
const tzInfo = getTimezoneOffset('JFK');
console.log(tzInfo);
// Output:
// {
// offsetHours: -5,
// timezone: 'America/New_York',
// isDST: false
// }
`
- iataCode (string): IATA airport code (e.g., 'JFK', 'LAX')
- localTime (string): Local time in 'YYYY-MM-DD HH:mm:ss' format 'YYYY-MM-DD HH:mm:ss'
- Returns: UTC time string in format
---
- iataCode (string): IATA airport code
- utcTime (string): UTC time in 'YYYY-MM-DD HH:mm:ss' format 'YYYY-MM-DD HH:mm:ss'
- Returns: Local time string in format
---
- sourceIATA (string): Source airport IATA code
- targetIATA (string): Target airport IATA code
- sourceTime (string): Source time in 'YYYY-MM-DD HH:mm:ss' format 'YYYY-MM-DD HH:mm:ss'
- Returns: Target time string in format
---
- iataCode (string): IATA airport code
- date (Date, optional): Date to check offset for (defaults to current date)
- Returns: Object containing offset information:
- offsetHours (number): Offset from UTC in hours timezone
- (string): Timezone name isDST
- (boolean): Whether DST is in effect
All functions will throw an Error if:
- ❌ An invalid IATA code is provided
- ❌ An invalid time format is used
- ❌ An invalid timezone conversion is attempted
- moment-timezone for reliable timezone calculations
MIT
1. Fork the repository
2. Create your feature branch (git checkout -b feature/amazing-feature) git commit -m 'Add some amazing feature'
3. Commit your changes () git push origin feature/amazing-feature`)
4. Push to the branch (
5. Open a Pull Request