JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 35
  • Score
    100M100P100Q63344F
  • License ISC

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. Built with moment-timezone for accurate daylight saving time handling.

Package Exports

  • iata-tz
  • iata-tz/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (iata-tz) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

iata-tz

iata-tz: A robust Node.js module for airport timezone conversion
Website | Getting Started | Documentation | API Reference | Contributing

✈️ Overview

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.

🚀 Installation

npm install iata-tz

🔥 Features

  • ✅ 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

🛠️ Usage

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
// }

📖 API Reference

convertToUTC(iataCode, localTime)

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

convertFromUTC(iataCode, utcTime)

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

convertBetweenTimezones(sourceIATA, targetIATA, sourceTime)

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

getTimezoneOffset(iataCode, [date])

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 hours
    • timezone (string): Timezone name
    • isDST (boolean): Whether DST is in effect

⚠️ Error Handling

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

📦 Dependencies

  • moment-timezone for reliable timezone calculations

📜 License

MIT

🛠️ Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request