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.
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
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
// }Converts local time at an airport to UTC.
- iataCode (string): IATA airport code (e.g., 'JFK', 'LAX')
- localTime (string): Local time in
'YYYY-MM-DD HH:mm:ss'format - Returns: UTC time string in
'YYYY-MM-DD HH:mm:ss'format
Converts UTC time to local time at an airport.
- iataCode (string): IATA airport code
- utcTime (string): UTC time in
'YYYY-MM-DD HH:mm:ss'format - Returns: Local time string in
'YYYY-MM-DD HH:mm:ss'format
Converts time between two airport timezones.
- sourceIATA (string): Source airport IATA code
- targetIATA (string): Target airport IATA code
- sourceTime (string): Source time in
'YYYY-MM-DD HH:mm:ss'format - Returns: Target time string in
'YYYY-MM-DD HH:mm:ss'format
Gets timezone information for an airport.
- 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 hourstimezone(string): Timezone nameisDST(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-timezonefor reliable timezone calculations
MIT
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request