new DateTime( time, date )

Description

Right Track Date Time

This class handles the various representations of dates and times used by the GTFS Spec and the Right Track Library and the various transformations between them.

Time Formats

  • string hh:mm aa (1:30 PM) | Human Readable Time
  • string HH:mm:ss (13:30:00) | GTFS Time
  • string HH:mm (13:30)
  • string HHmm (1330)
  • int seconds since midnight (7:00 am = 25200) | Time Seconds

Date Formats

  • int yyyymmdd (20170930) | Date Integer

Module: utils/DateTime

Parameters
Name Type Description
time string | int

String or Integer representation of the time. Can be in one of the following formats: 1) HH:mm:ss 2) HH:mm 3) HHmm 4) h:mm aa or 5) an integer of the number of seconds since midnight (ex 7:00 am = 25200)

date int

The date of the DateTime in the format yyyymmdd

Details

Methods


deltaDays( delta ) → {DateTime}

Description

Add or Subtract the specified number of days to the DateTime's date

Parameters
Name Type Description
delta

+/- number of days to add

Returns

return the DateTime

Details

deltaMins( delta ) → {DateTime}

Description

Add or Subtract the specified number of minutes to the DateTime's time

Parameters
Name Type Description
delta

+/- number of minutes to add

Returns

return the DateTime

Details

getTimeSeconds() → {int}

Description

Get the time in seconds since midnight

Returns

time integer in seconds

Details

getTimeInt() → {string}

Description

Get the Time in HHmm format

Returns

HHmm

Details

getTimeGTFS() → {string}

Description

Get the GTFS Spec time representation (HH:mm:ss)

Returns

GTFS Time (HH:mm:ss)

Details

getTimeReadable() → {string}

Description

Get the human readable time (12 hr with AM/PM)

Returns

human readable time

Details

isDateSet() → {boolean}

Description

Check if the date is set

Returns

true if the date is set

Details

getDateInt() → {int}

Description

Get the integer representation of the date (yyyymmdd)

Returns

date integer (yyyymmdd)

Details

getDateDOW() → {string}

Description

Get the full name of the weekday of the date (monday, tuesday, etc)

Returns

day of week

Details

getDateReadable( dow ) → {string}

Description

Get the human readable date ([Thu, ]Apr 18, 2019)

Parameters
Name Type Description
dow boolean

When true, include the day of the week

Returns

human readable date

Details

toMySQLString() → {string}

Description

Get a String representation of the DateTime to be used as a MySQL DateTime

Returns

MySQL DateTime String

Details

toHTTPString() → {string}

Description

Get a String representation of the DateTime to be used in HTTP Headers

Returns

HTTP Header String

Details

toTimestamp() → {number}

Description

Get a timestamp (in ms) of the DateTime

Returns

timestamp (ms) of DateTime

Details

toString() → {string}

Description

Get a String representation of the DateTIme

Returns

string of DateTime

Details

clone() → {DateTime}

Description

Create a new DateTime Object with the properties of this one

Returns

DateTime with same date and time

Details

<static> create( time, date ) → {DateTime}

Description

DateTime Factory: with time and date

Parameters
Name Type Description
time string | int

Time

date int

Date

Returns

DateTime

Details

<static> now() → {DateTime}

Description

DateTime Factory: date and time of now

Returns

DateTime

Details

<static> createFromJSDate( jd )

Description

DateTime Factory: with JavaScript Date

Parameters
Name Type Description
jd Date

JavaScript Date

Details

<static> createFromTime( time [, guessDate ] ) → {DateTime}

Description

DateTime Factory: with time

Parameters
Name Type Attributes Default Description
time string

Time

guessDate boolean <optional>
false

Set to true to guess the Date relative to today

Returns

DateTime

Details

<static> createFromDate( date ) → {DateTime}

Description

DateTime Factory: with date

Parameters
Name Type Description
date int

Date

Returns

DateTime

Details