Class: AstroDate

astrodate~ AstroDate

This is what becomes exported or made global.

Constructor

new AstroDate(…argumentsopt) → {AstroDate}

Used to create a new instance of a date.

new AstroDate();
new AstroDate(value);
new AstroDate(dateString);
new AstroDate(dateObject);
new AstroDate(astroDateObject);
new AstroDate(year[, month, day, hour, minute, second, millisecond, offset][, options]);
  • value
    Integer value representing the number of milliseconds since 1 January 1970 00:00:00 UTC (Unix Epoch).
  • dateString
    String value representing a date. The string must be in the format of ISO8601.
  • dateObject
    A Javascript Date object.
  • astroDateObject
    An AstroDate object.
  • year
    Integer or string value representing the year. The year must always be provided in full (e.g. 98 is treated as 98, not 1998).
  • month
    Integer or string value representing the month, beginning with 0 for January to 11 for December.
  • day
    Integer or string value representing the day of the month.
  • hour
    Integer or string value representing the hour of the day.
  • minute
    Integer or string value representing the minute segment of a time.
  • second
    Integer or string value representing the second segment of a time.
  • millisecond
    Integer or string value representing the millisecond segment of a time.
  • offset
    Integer or string value representing the offset from UT in seconds.
  • options
    null or object Must be used when only year is specified. Allows date to be specified in Julian Calender (more/changes coming).
This:
Parameters:
Name Type Attributes Description
arguments * <optional>
<repeatable>
Source:
Returns:
Type
AstroDate
Example

Example usage of constructor.

// If no arguments are provided, the constructor creates an AstroDate object for the
// current date and time according to system settings.
new AstroDate();

// Integer value representing the number of milliseconds since 1 January 1970 00:00:00 UTC (Unix Epoch).
// -9,007,199,254,740,992 to 9,007,199,254,740,992 or NaN
new AstroDate(819170640000); //1995-12-17T03:24:00.000Z
new AstroDate(NaN); //Invalid Date

// String value representing a date. The string must be in the format of ISO8601.
new AstroDate('1995-12-17T03:24:00.000Z');

// A Javascript Date object.
new AstroDate(new Date(1995, 12, 17, 3, 24, 0, 0));

// An AstroDate object.
new AstroDate(new AstroDate(1995, 12, 17, 3, 24, 0, 0, 3600)); // offset is same as '-01:00:00'

// Using an arguments list.
new AstroDate(1995, null);
new AstroDate(1995, {offset: -3600}); // offset is same as '+01:00:00'
new AstroDate(55, {julian: true, offset: -3600});
// year 55 of the Julian Calendar, offset is same as '+01:00:00'
new AstroDate(1995, 12, 17, 3, 24, 0, 0, -3600); // offset is same as '+01:00:00'
new AstroDate('1995', '12', '17', '3', '24', '0', '0', '-5400'); // offset is same as '+01:30:00'
new AstroDate('1995', '12', '17', '3', '24', '0', '0', '+01:30:00'); // offset is same as -5400
new AstroDate('-10', '5', '7', {julian: true}); // year -10 of the Julian Calendar