Loading...
Searching...
No Matches
supernovas::Calendar Class Reference
Time of observation and astronomical timescales

Type of calendar used for representing dates, such as Gregorian, Roman, or astronomical. More...

`#include <supernovas.h>`

Inheritance diagram for supernovas::Calendar:

## Public Member Functions

CalendarDate | date (const struct timespec *ts) const
| Returns a new calendar date instance, in this calendar, for the given astronomical time specification.
CalendarDate | date (double jd) const
| Returns a new calendar date instance, in this calendar, for the specified Julian date.
CalendarDate | date (int year, int month, int day, const TimeAngle &time=TimeAngle::zero()) const
| Returns a new calendar date instance for the date and time specified in this calendar.
CalendarDate | date (time_t t, long nanos=0) const
| Returns a new calendar date instance, in this calendar, for the specified UNIX time.
CalendarDate | parse_date (const std::string &str, enum novas_date_format fmt=NOVAS_YMD) const
| Returns a new calendar date instance, in this calendar, for the specified string date / time representation, if possible, or else an undefined (invalid) date.
std::string | to_string () const
| Returns a string representation of this type of calendar.
enum novas_calendar_type | type () const
| Returns the type of this calendar, that is whether it is a Gregorian, Roman / Julian, or astronomical calendar.
Public Member Functions inherited from supernovas::Validating
bool | is_valid () const
| Returns the previously set 'valid' state of the implementing instance.
| operator bool () const
| Objects that implement Validating can be used in conditionals directly, without explicitly calling is_valid().

## Static Public Member Functions

static Calendar | astronomical ()
| Returns a new astronomical calendar instance.
static Calendar | gregorian ()
| Returns a new Gregorian calendar instance.
static Calendar | roman ()
| Returns a new Roman / Julian calendar instance.

## Additional Inherited Members

Protected Member Functions inherited from supernovas::Validating
| Validating ()
| dummy constructor;
Protected Attributes inherited from supernovas::Validating
bool | _valid = false
| the state variable.

## Detailed Description

Type of calendar used for representing dates, such as Gregorian, Roman, or astronomical.

Since
  1.6

## Member Function Documentation

## astronomical()

Calendar supernovas::Calendar::astronomical | ( |  | ) |

static

Returns a new astronomical calendar instance.

The astronomical calendat is the conventional calendar of date, that is the Roman / Julian calendar prior to the Gregorian calendar reform of 1582; and the Gregorian calendar after the date of the reform.

Returns
  an astronomical calendar / conventional calendar of date instance.

Since
  1.6

See also
  roman(), gregorian()

References astronomical(), and NOVAS_ASTRONOMICAL_CALENDAR.

Referenced by astronomical(), supernovas::Time::operator-(), and supernovas::Time::to_calendar_date().

## date() [1/4]

CalendarDate supernovas::Calendar::date | ( | const struct timespec * | ts | ) | const

Returns a new calendar date instance, in this calendar, for the given astronomical time specification.

Parameters

  ts | Pointer to the astronomical time specification

Returns
  a new calendar date, in this calendar, corresponding to the specified astronomical time.

Since
  1.6

See also
  date(), parse_date()

References date().

## date() [2/4]

CalendarDate supernovas::Calendar::date | ( | double | jd | ) | const

Returns a new calendar date instance, in this calendar, for the specified Julian date.

Parameters

  jd | [day] Julian Day

Returns
  a new calendar date, in this calendar, corresponding to the specified Julian date.

Since
  1.6

See also
  CalendarDate::CalendarDate(), date(), parse_date()

References date(), and supernovas::Validating::is_valid().

## date() [3/4]

CalendarDate supernovas::Calendar::date | ( | int | year,
|  | int | month,
|  | int | day,
|  | const TimeAngle & | time = TimeAngle::zero() ) const

Returns a new calendar date instance for the date and time specified in this calendar.

Parameters

  year | [yr] calendar year
  month | [month] calendar month [1:12]
  day | [day] calendar day-of-month [1:31]
  time | time of day

Returns
  a date instance for the specified date in this calendar.

Since
  1.6

See also
  CalendarDate::CalendarDate(), date(), parse_date()

References date(), and supernovas::Validating::is_valid().

Referenced by date(), date(), date(), date(), parse_date(), and supernovas::Time::to_calendar_date().

## date() [4/4]

CalendarDate supernovas::Calendar::date | ( | time_t | t,
|  | long | nanos = 0 ) const

Returns a new calendar date instance, in this calendar, for the specified UNIX time.

Parameters

  t | [s] UNIX time (seconds since the Gregorian date of January 1, 1970).
  nanos | [ns] sub-second time component

Returns
  a new calendar date, in this calendar, corresponding to the specified UNIX time.

Since
  1.6

See also
  date(), date(double)

References date(), supernovas::Unit::day, NOVAS_JD_J2000, and supernovas::Unit::ns.

## gregorian()

Calendar supernovas::Calendar::gregorian | ( |  | ) |

static

Returns a new Gregorian calendar instance.

Returns
  a Gregorian calendar instance

Since
  1.6

See also
  roman(), astronomical()

References gregorian(), and NOVAS_GREGORIAN_CALENDAR.

Referenced by gregorian().

## parse_date()

CalendarDate supernovas::Calendar::parse_date | ( | const std::string & | str,
|  | enum novas_date_format | fmt = NOVAS_YMD ) const

Returns a new calendar date instance, in this calendar, for the specified string date / time representation, if possible, or else an undefined (invalid) date.

Parameters

  str | The string date / time specification. There is a lot of flexibility on what dates/times may be parsed. See novas_parse_date_format() for details.
  fmt | The date representation, such as NOVAS_YMD, NOVAS_DMY, or NOVAS_MDY, specifying the order in which the year (Y), month (M), and day (D) components are expected in the input string representation.

Returns
  A new calendar date, in this calendar, or else CalendarDate::undefined() if the string date could not be parsed.

Since
  1.6

See also
  CalendarDate::to_string(), date()
  novas_parse_date(), novas_parse_ido_date(), novas_parse_date_format() for more managed parsing from strings.

References date(), novas_parse_date_format(), parse_date(), and supernovas::CalendarDate::undefined().

Referenced by parse_date().

## roman()

Calendar supernovas::Calendar::roman | ( |  | ) |

static

Returns a new Roman / Julian calendar instance.

Returns
  a Roman / Julian calendar instance

Since
  1.6

See also
  gregorian(), astronomical()

References NOVAS_ROMAN_CALENDAR, and roman().

Referenced by roman().

## to_string()

std::string supernovas::Calendar::to_string | ( |  | ) | const

Returns a string representation of this type of calendar.

Returns
  A string representation of the calendar, such as "Gregorian calendar".

Since
  1.6

References NOVAS_GREGORIAN_CALENDAR, NOVAS_ROMAN_CALENDAR, and to_string().

Referenced by to_string().

## type()

enum novas_calendar_type supernovas::Calendar::type | ( |  | ) | const

Returns the type of this calendar, that is whether it is a Gregorian, Roman / Julian, or astronomical calendar.

The astronomical calendat is the conventional calendar of date.

Returns
  The type of calendar, e.g. NOVAS_GREGORIAN_CALENDAR, NOVAS_ROMAN_CALENDAR, or NOVAS_ASTRONOMICAL calendar.

Since
  1.6

References type().

Referenced by type().