Skip to content

Commit

Permalink
adding methods to get the header summaries in the selected date mode
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipsOwen committed Nov 8, 2024
1 parent f852cde commit 3a4903d
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/utils/map-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,37 @@ export const getPropertyName = (layerProps, element_name) => {
return ret_val;
};

/**
* gets the run date formatted based on current user UTC/locale selection
*
* @param layerProps
* @param useUTC
* @param longFormat
* @returns {string|string}
*/
export const getPreferredTimeZone = (layerProps, useUTC, longFormat=false) => {
// does the situation need the full date format
if (longFormat) {
return useUTC ? new Date(layerProps['runDate']).toUTCString() : new Date(layerProps['insertion_date']).toLocaleString();
}
// send back the short date format
else {
// get the date/time by current preference
return useUTC ? layerProps['run_date'] : new Date(layerProps['insertion_date']).toLocaleDateString();
}

};

/**
* gets the summary header text for the layer groups.
* This takes into account the two types of runs (tropical, synoptic)
*
* @param layerProps
* @returns {string}
*/
export const getHeaderSummary = (layerProps) => {
export const getHeaderSummary = (layerProps, useUTC) => {
// get the full accordian summary text
return layerProps['run_date'] + ': ' +
return getPreferredTimeZone(layerProps, useUTC) + ': ' +
((getPropertyName(layerProps, 'stormOrModelEle') === undefined) ? 'Data error' : getPropertyName(layerProps, 'stormOrModelEle').toUpperCase()) +
', ' + getPropertyName(layerProps, 'numberName') + getPropertyName(layerProps, 'numberEle') +
', Type: ' + layerProps['event_type'] +
Expand Down Expand Up @@ -186,7 +207,6 @@ export const markClicked = (map, event, id) => {
marker.addTo(map);
};


export const markUnclicked = (map, id) => {
map.eachLayer((layer) => {
if (layer.options && layer.options.pane === "markerPane") {
Expand Down

0 comments on commit 3a4903d

Please sign in to comment.