airac

package module
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

airac: a small Go library for calculating aviation AIRAC cycle dates

Apache License v2.0 GoDoc Build Status Go Report codebeat badge codecov

Package airac provides calculations on Aeronautical Information Regulation And Control (AIRAC) cycles, i.e. cycle identifiers and effective calendar dates.

Regular, planned Aeronautical Information Publications (AIP) as defined by the International Civil Aviation Organization (ICAO) are published and become effective at fixed dates. This package implements the AIRAC cycle definition as published in the ICAO Aeronautical Information Services Manual (DOC 8126; AN/872; 6th Edition; 2003). Test cases validate documented dates from 1998 until 2020, including the rare case of a 14th cycle in the year 2020.

License

Licensed under the Apache License, Version 2.0.

See also

A Java port is available at github.com/jwkohnen/airac-java/.

Wikipedia

Article on AIP / AIRAC cycles: https://en.wikipedia.org/wiki/Aeronautical_Information_Publication

There are wiki macros in that article that do basically the same thing as this library. Though, this library does not trip over the case of 14 cycles per year (e. g. 1998 and 2020).

Documentation

Overview

Package airac provides calculations on Aeronautical Information Regulation And Control (AIRAC) cycles, i.e. cycle identifiers and effective calendar dates.

Regular, planned Aeronautical Information Publications (AIP) as defined by the International Civil Aviation Organization (ICAO) are published and become effective at fixed dates. This package implements the AIRAC cycle definition as published in the ICAO Aeronautical Information Services Manual (DOC 8126; AN/872; 6th Edition; 2003). Test cases validate documented dates from 1998 until 2020, including the rare case of a 14th cycle in the year 2020.

Licensed under the Apache License, Version 2.0.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIRAC added in v1.0.4

type AIRAC uint16

AIRAC represents an Aeronautical Information Regulation And Control (AIRAC) cycle.

func FromDate

func FromDate(date time.Time) AIRAC

FromDate returns the AIRAC cycle that occurred at date. A date before the internal epoch (1901-01-10) may return wrong data. The upper limit is year 2192.

Example
shalom := time.Date(2012, time.August, 26, 0, 0, 0, 0, time.UTC)
airac := FromDate(shalom)

fmt.Printf("At %s the current AIRAC cycle was %s.\n\n",
	shalom.Format("2006-01-02"),
	airac.LongString(),
)

fmt.Printf("Short identifier: %s", airac)
Output:

At 2012-08-26 the current AIRAC cycle was 1209 (effective: 2012-08-23; expires: 2012-09-19).

Short identifier: 1209

func FromString

func FromString(yyoo string) (AIRAC, error)

FromString returns an AIRAC cycle that matches the identifier <yyoo>, i.e. the last two digits of the year and the ordinal, each with leading zeros. This works for years between 1964 and 2063. Identifiers between "6401" and "9913" are interpreted as AIRAC cycles between the years 1964 and 1999 inclusive. AIRAC cycles between "0001" and "6313" are interpreted as AIRAC cycles between the years 2000 and 2063 inclusive.

func FromStringMust

func FromStringMust(yyoo string) AIRAC

FromStringMust returns an AIRAC cycle that matches the identifier <yyoo> like FromString, but does not return an error. If there is an error it will panic instead.

func (AIRAC) Effective added in v1.0.4

func (a AIRAC) Effective() time.Time

Effective returns the effective date of this AIRAC cycle.

func (AIRAC) LongString added in v1.0.4

func (a AIRAC) LongString() string

LongString returns a verbose representation of this AIRAC cycle. "YYOO (effective: YYYY-MM-DD; expires: YYYY-MM-DD)"

func (AIRAC) Ordinal added in v1.0.4

func (a AIRAC) Ordinal() int

Ordinal returns the ordinal for this AIRAC cycle's identifier.

func (AIRAC) String added in v1.0.4

func (a AIRAC) String() string

String returns a short representation of this AIRAC cycle. "YYOO"

func (AIRAC) Year added in v1.0.4

func (a AIRAC) Year() int

Year returns the year for this AIRAC cycle's identifier.

type Airac

type Airac = AIRAC

Airac is a deprecated alias to AIRAC.

type ByChrono

type ByChrono []AIRAC

ByChrono is an []AIRAC wrapper, that satisfies sort.Interface and can be used to chronologically sort AIRAC instances.

Example
airacs := []AIRAC{
	FromStringMust("1213"),
	FromStringMust("1201"),
	FromStringMust("1207"),
}
fmt.Println("Not Sorted:    ", airacs)

sort.Sort(ByChrono(airacs))
fmt.Println("Sorted:        ", airacs)

sort.Sort(sort.Reverse(ByChrono(airacs)))
fmt.Println("Sorted reverse:", airacs)
Output:

Not Sorted:     [1213 1201 1207]
Sorted:         [1201 1207 1213]
Sorted reverse: [1213 1207 1201]

func (ByChrono) Len

func (c ByChrono) Len() int

Len ist the number of elements in the collection.

func (ByChrono) Less

func (c ByChrono) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (ByChrono) Swap

func (c ByChrono) Swap(i, j int)

Swap swaps the elements with indexes i and j.

Notes

Bugs

  • The two digit year identifier of the FromString method will

    interpret the year as between 1964 and 2063. Other methods than FromString do
    not show this range restriction. This time window is more or less arbitrary and
    may change.
    
  • This package assumes that AIRAC cycles are effective from

    the effective date at 00:00:00 UTC until 27 days later at 23:59:59.999999999
    UTC. That is not correct:
    
    ICAO DOC 8126, 6th Edition (2003), paragraph 2.6.4:
    "In addition to the use of a predetermined schedule of effective AIRAC dates,
    Coordinated Universal Time (UTC) must also be used to indicate the time when
    the AIRAC information will become effective. Since Annex 15, paragraph 3.2.3
    specifies that the Gregorian calendar and UTC must be used as the temporal
    reference system for international civil aviation, in addition to AIRAC
    dates, 00:01 UTC must be used to indicate the time when the AIRAC-based
    information will become effective."
    
    However I won't "fix" this, because that may just confuse users.
    
  • Calculations that include calendar dates before the internal

    epoch (1901-01-10; 63 years before the AIRAC system was introduced by the ICAO)
    and after year 2192 may silently produce wrong data.
    
  • This package only provides calculations on effective dates,

    not publication or reception dates etc. Although effective dates are clearly
    defined and are consistent at least between 1998 until 2020, the derivative
    dates changed historically.[citation needed]
    

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL