Methods
(static) countdown(date) → {Object}
- Source:
A helper function that can return the pieces for a countdown clock relative to a specified date
Parameters:
Name | Type | Description |
---|---|---|
date |
Date | The date we are counting down to |
Returns:
An object with days, minutes, hours, seconds,
- Type
- Object
(static) dateFromID(id, format, timezone) → {String}
- Source:
Parses an ObjectID and returns the date of creation
Example
var id = '5ca3d64dd2bb085eb9d450db'
return dateFromID.formatDate(id, 'D M YYYY')
Parameters:
Name | Type | Description |
---|---|---|
id |
String | The id of the object to parse |
format |
String | A string representing the format to output for formatting syntax see https://momentjs.com/docs/#/displaying/format/ |
timezone |
String | The timezone to use if needing to translate the date to another timezone eg. Australia/Melbourne |
Returns:
A human readable string
- Type
- String
(static) formatDate(date, format, timezone) → {String}
- Source:
Parses a date and returns a human readable date string
Example
var date = new Date()
return fluro.date.formatDate(date, 'h:mma DDD MMM YYYY')
var dateString = '2019-04-18T23:00:00.000Z'
return fluro.date.formatDate(dateString, 'D M YYYY', 'Australia/Melbourne')
Parameters:
Name | Type | Description |
---|---|---|
date |
Date | String | The date or string to parse |
format |
String | A string representing the format to output for formatting syntax see https://momentjs.com/docs/#/displaying/format/ |
timezone |
String | The timezone to use if needing to translate the date to another timezone eg. Australia/Melbourne |
Returns:
A human readable string
- Type
- String
(static) getAge() → {Integer}
- Source:
A helpful function that can quickly get an age from a supplied date string
Example
fluro.date.getAge('2019-04-18T23:00:00.000Z')
Returns:
The age in years
- Type
- Integer
(static) groupEventByDate(events) → {Array}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
events |
Array | The events we want to group |
Returns:
A grouped array of dates and events
- Type
- Array
(static) isDifferentTimezoneThanUser() → {Boolean}
- Source:
A function that returns all of the available timezones. Often used to populate a select box
Returns:
True if the specified timezone is different than the viewing user
- Type
- Boolean
(static) isMultiDayEvent(event) → {Boolean}
- Source:
Checks whether an event spans over multiple days
Example
return fluro.date.isMultiDayEvent({startDate:...})
Parameters:
Name | Type | Description |
---|---|---|
event |
Object | A Fluro event object with a startDate and an endDate |
Returns:
True or False if the event spans multiple days
- Type
- Boolean
(static) localDate(date, specifiedTimezone) → {Date}
- Source:
A function that will return a date in context of a specified timezone
If no timezone is specified then the default timezone of the current clock will be used.
This will return dates that are incorrect on purpose. So that it can appear to the user as if they were in another timezone.
As Javascript dates are always in the context of the timezone they are being viewed in, this function will give you a date that is technically
not the Universal point in time of the date, but rather a time that reads in your timezone as if you were in the specified timezone.
Parameters:
Name | Type | Description |
---|---|---|
date |
Date | Either a javascript date object, or a string timestamp representing a javascript date object |
specifiedTimezone |
String | The timezone to retrieve the date in eg. Australia/Melbourne |
Returns:
A javascript date object transformed to match the specified timezone
- Type
- Date
(static) militaryTimestamp() → {String}
- Source:
A function that converts a timestamp string '7:30' to '0730';
Returns:
- Type
- String
(static) readableEventDate(event, style) → {String}
- Source:
A helper function that can display a human-readable date for an event
taking into consideration the context of the current time, the event's start and end time.
This is often used as a string filter
and what is relevant
Example
//Returns 5:30pm 1 May
fluro.date.readableEventDate({"startDate": "2019-05-01T07:30:00.000Z", "endDate":"2019-05-01T07:30:00.000Z"})
//Returns 5:30pm - 7:30pm 1 May
fluro.date.readableEventDate({"startDate": "2019-05-01T07:30:00.000Z", "endDate":"2019-05-01T09:30:00.000Z"})
//Returns 1 - 5 May 2015
fluro.date.readableEventDate({"startDate": "2015-05-01T07:30:00.000Z", "endDate":"2015-05-05T09:30:00.000Z"})
//1 May - 21 Jun 2019
fluro.date.readableEventDate({"startDate": "2019-05-01T07:30:00.000Z", "endDate":"2019-06-21T09:30:00.000Z"})
Parameters:
Name | Type | Description |
---|---|---|
event |
Object | An object that has both a startDate and endDate property, Usually an event object from the Fluro API |
style |
String | Whether to return a 'short', 'medium' or 'long' date |
Returns:
The human readable date for the event
- Type
- String
(static) readableEventTime(event) → {String}
- Source:
A helper function that can display a human-readable time for an event
taking into consideration the context of the current time, the event's start and end time.
This is often used as a string filter
Example
//Returns 5:30pm
fluro.date.readableEventTime({"startDate": "2019-05-01T07:30:00.000Z", "endDate":null})
//Returns 5:30pm - 7:30pm
fluro.date.readableEventTime({"startDate": "2019-05-01T07:30:00.000Z", "endDate":"2019-05-01T09:30:00.000Z"})
Parameters:
Name | Type | Description |
---|---|---|
event |
Object | An object that has both a startDate and endDate property, Usually an event object from the Fluro API |
Returns:
The human readable time for the event
- Type
- String
(static) timeago(date) → {String}
- Source:
Parses a date and returns a 'timeago' string
Example
var date = new Date()
//Returns 10 mins ago
return fluro.date.timeago(date)
Parameters:
Name | Type | Description |
---|---|---|
date |
Date | String | The date or string to parse |
Returns:
A human readable string
- Type
- String
(static) timeline(items) → {Array}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
items |
Array | The items we want to group on the timeline |
Returns:
A grouped array of dates
- Type
- Array
(static) timestampToAmPm() → {String}
- Source:
A function that converts a timestamp string '13:30' to '1:30pm';
Returns:
A formatted timestamp string
- Type
- String
(static) timezones() → {Array}
- Source:
A function that returns all of the available timezones. Often used to populate a select box
Returns:
An array of all availble timezones.
- Type
- Array