Skip to content

Commit

Permalink
Merge pull request #17 from erenken/work/dateFormat
Browse files Browse the repository at this point in the history
Work/date format
  • Loading branch information
erenken committed Apr 5, 2023
2 parents ccac71c + a15d554 commit 2594d91
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 29 deletions.
1 change: 1 addition & 0 deletions rw-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { HighLowWeather } from './utilities/HighLowWeather';
import React from 'react';
import { IWeatherState } from './_IWeatherState';
import { INameProperty } from './_INameProperty';
import {} from './utilities/DateExtensions';

class App extends React.Component<INameProperty, IWeatherState>{
constructor(props: any) {
Expand Down
2 changes: 1 addition & 1 deletion rw-app/src/components/AirQuaility.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AirQuaility extends React.Component<{ weather: CurrentWeather | undefined
</Card.Body>
{this.airLink.LastReportTime &&
<Card.Footer>
<div>{new Date(this.airLink.LastReportTime).toLocaleString()}</div>
<div>{new Date(this.airLink.LastReportTime).toDisplayFormat()}</div>
</Card.Footer>
}
</Card>
Expand Down
2 changes: 1 addition & 1 deletion rw-app/src/components/CurrentConditions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CurrentConditions extends React.Component<{ weather: CurrentWeather | unde
</Card.Body>
{this.vantagePro &&
<Card.Footer>
<div>{new Date(this.vantagePro.TimeStamp).toLocaleString()}</div>
<div>{new Date(this.vantagePro.TimeStamp).toDisplayFormat()}</div>
</Card.Footer>
}
</Card>
Expand Down
6 changes: 3 additions & 3 deletions rw-app/src/components/RainStorm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RainStorm extends React.Component<{ weather: CurrentWeather | undefined }>
<>
<Row>
<Col>Started</Col>
<Col align='end'>{new Date(this.vantagePro?.RainStormStartTime).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantagePro?.RainStormStartTime).toDisplayFormat()}</Col>
</Row>
<Row>
<Col>Length</Col>
Expand Down Expand Up @@ -55,11 +55,11 @@ class RainStorm extends React.Component<{ weather: CurrentWeather | undefined }>
<Card.Body>
<Row>
<Col>Started</Col>
<Col align='end'>{new Date(this.vantagePro.RainStormLastStartAt).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantagePro.RainStormLastStartAt).toDisplayFormat()}</Col>
</Row>
<Row>
<Col>Ended</Col>
<Col align='end'>{new Date(this.vantagePro.RainStormLastEndAt).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantagePro.RainStormLastEndAt).toDisplayFormat()}</Col>
</Row>
<Row>
<Col>Duration</Col>
Expand Down
4 changes: 2 additions & 2 deletions rw-app/src/pages/GraphsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ class GraphsPage extends React.Component<INameProperty, IGraphState> {

this.state = {
historical: undefined,
days: 6
days: 0
};
}

async componentDidMount() {
await this.getHistoric(6);
await this.getHistoric(0);
}

private async getHistoric(days: number) {
Expand Down
40 changes: 20 additions & 20 deletions rw-app/src/pages/HighLowPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class HighLowPage extends React.Component<{
<Row>
<Col>High</Col>
<Col align='end'>{this.vantageProArchive?.temp_hi}&deg; F</Col>
<Col align='end'>{new Date(this.vantageProArchive?.TemperatureHighAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.TemperatureHighAt!).toDisplayFormat()}</Col>
</Row>
<Row>
<Col>Low</Col>
<Col align='end'>{this.vantageProArchive?.temp_lo}&deg; F</Col>
<Col align='end'>{new Date(this.vantageProArchive?.TemperatureLowAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.TemperatureLowAt!).toDisplayFormat()}</Col>
</Row>
<Row>
<Col>Average</Col>
Expand All @@ -50,30 +50,30 @@ class HighLowPage extends React.Component<{
<Row>
<Col>Heat Index</Col>
<Col align='end'>{this.vantageProArchive?.heat_index_hi}&deg; F</Col>
<Col align='end'>{new Date(this.vantageProArchive?.HeatIndexHighAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.HeatIndexHighAt!).toDisplayFormat()}</Col>
</Row>
{this.vantageProArchive?.temp_lo && this.vantageProArchive?.temp_lo <= 45 &&
<>
<Row>
<Col>Low Wind Chill</Col>
<Col align='end'>{this.vantageProArchive?.wind_chill_lo}&deg; F</Col>
<Col align='end'>{new Date(this.vantageProArchive?.WindChillLowAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.WindChillLowAt!).toDisplayFormat()}</Col>
</Row>
</>
}
<Row>
<Col>Feels Like High</Col>
<Col align='end'>{this.vantageProArchive?.thsw_index_hi}&deg; F</Col>
<Col align='end'>{new Date(this.vantageProArchive?.THSWIndexHighAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.THSWIndexHighAt!).toDisplayFormat()}</Col>
</Row>
<Row>
<Col>Feels Like Low</Col>
<Col align='end'>{this.vantageProArchive?.thsw_index_lo}&deg; F</Col>
<Col align='end'>{new Date(this.vantageProArchive?.thsw_index_lo_at!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.thsw_index_lo_at!).toDisplayFormat()}</Col>
</Row>
</Card.Body>
<Card.Footer>
{new Date(this.props.highLows?.GeneratedAt!).toLocaleString()}
{new Date(this.props.highLows?.GeneratedAt!).toDisplayFormat()}
</Card.Footer>
</Card>
<br />
Expand All @@ -85,7 +85,7 @@ class HighLowPage extends React.Component<{
<Row>
<Col>High</Col>
<Col align='end'>{this.vantageProArchive?.wind_speed_hi} mph</Col>
<Col align='end'>{new Date(this.vantageProArchive?.WindSpeedHighAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.WindSpeedHighAt!).toDisplayFormat()}</Col>
</Row>
<Row>
<Col>Total Run</Col>
Expand All @@ -94,7 +94,7 @@ class HighLowPage extends React.Component<{
</Row>
</Card.Body>
<Card.Footer>
{new Date(this.props.highLows?.GeneratedAt!).toLocaleString()}
{new Date(this.props.highLows?.GeneratedAt!).toDisplayFormat()}
</Card.Footer>
</Card>
<br />
Expand All @@ -106,7 +106,7 @@ class HighLowPage extends React.Component<{
<Row>
<Col>Rate High</Col>
<Col align='end'>{this.vantageProArchive?.rain_rate_hi_in} in</Col>
<Col align='end'>{new Date(this.vantageProArchive?.RainRateHighAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.RainRateHighAt!).toDisplayFormat()}</Col>
</Row>
<Row>
<Col>Total Day</Col>
Expand All @@ -125,7 +125,7 @@ class HighLowPage extends React.Component<{
</Row>
</Card.Body>
<Card.Footer>
{new Date(this.props.highLows?.GeneratedAt!).toLocaleString()}
{new Date(this.props.highLows?.GeneratedAt!).toDisplayFormat()}
</Card.Footer>
</Card> <br />
<Card>
Expand All @@ -136,16 +136,16 @@ class HighLowPage extends React.Component<{
<Row>
<Col>High</Col>
<Col align='end'>{this.vantageProArchive?.hum_hi}%</Col>
<Col align='end'>{new Date(this.vantageProArchive?.HumidityHighAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.HumidityHighAt!).toDisplayFormat()}</Col>
</Row>
<Row>
<Col>Low</Col>
<Col align='end'>{this.vantageProArchive?.hum_lo}%</Col>
<Col align='end'>{new Date(this.vantageProArchive?.HumidityLowAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.HumidityLowAt!).toDisplayFormat()}</Col>
</Row>
</Card.Body>
<Card.Footer>
{new Date(this.props.highLows?.GeneratedAt!).toLocaleString()}
{new Date(this.props.highLows?.GeneratedAt!).toDisplayFormat()}
</Card.Footer>
</Card>
<br />
Expand All @@ -157,16 +157,16 @@ class HighLowPage extends React.Component<{
<Row>
<Col>High</Col>
<Col align='end'>{this.vantageProArchive?.dew_point_hi}&deg; F</Col>
<Col align='end'>{new Date(this.vantageProArchive?.DewPointHighAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.DewPointHighAt!).toDisplayFormat()}</Col>
</Row>
<Row>
<Col>Low</Col>
<Col align='end'>{this.vantageProArchive?.dew_point_lo}&deg; F</Col>
<Col align='end'>{new Date(this.vantageProArchive?.DewPointLowAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.DewPointLowAt!).toDisplayFormat()}</Col>
</Row>
</Card.Body>
<Card.Footer>
{new Date(this.props.highLows?.GeneratedAt!).toLocaleString()}
{new Date(this.props.highLows?.GeneratedAt!).toDisplayFormat()}
</Card.Footer>
</Card>
<br />
Expand All @@ -178,7 +178,7 @@ class HighLowPage extends React.Component<{
<Row>
<Col>High</Col>
<Col align='end'>{this.vantageProArchive?.uv_index_hi} Index</Col>
<Col align='end'>{new Date(this.vantageProArchive?.UVIndexHighAt!).toLocaleString()}</Col>
<Col align='end'>{new Date(this.vantageProArchive?.UVIndexHighAt!).toDisplayFormat()}</Col>
</Row>
<Row>
<Col>Average</Col>
Expand All @@ -192,7 +192,7 @@ class HighLowPage extends React.Component<{
</Row>
</Card.Body>
<Card.Footer>
{new Date(this.props.highLows?.GeneratedAt!).toLocaleString()}
{new Date(this.props.highLows?.GeneratedAt!).toDisplayFormat()}
</Card.Footer>
</Card>
<br />
Expand All @@ -218,7 +218,7 @@ class HighLowPage extends React.Component<{
</Row>
</Card.Body>
<Card.Footer>
{new Date(this.props.highLows?.GeneratedAt!).toLocaleString()}
{new Date(this.props.highLows?.GeneratedAt!).toDisplayFormat()}
</Card.Footer>
</Card>
</Container>
Expand Down
2 changes: 1 addition & 1 deletion rw-app/src/utilities/AppInsights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const browserHistory = createBrowserHistory();
var reactPlugin = new ReactPlugin();
var appInsights = new ApplicationInsights({
config: {
connectionString: 'InstrumentationKey=fbe35df1-a97d-4f8d-9c03-eb1f0204eff4;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/',
connectionString: 'InstrumentationKey=404ea136-773d-4f73-846d-3f6953ec3e04;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/',
extensions: [reactPlugin],
extensionConfig: {
[reactPlugin.identifier]: { history: browserHistory }
Expand Down
17 changes: 17 additions & 0 deletions rw-app/src/utilities/DateExtensions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export {}

declare global {
interface Date {
toDisplayFormat(): string;
}
}

Date.prototype.toDisplayFormat = function () {
return new Date(this).toLocaleString('en-us', {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: '2-digit'
});
};
2 changes: 1 addition & 1 deletion rw-app/src/utilities/NOAA.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WeatherAlerts } from "./WeatherAlerts";

export async function getWeatherAlerts(): Promise<WeatherAlerts | undefined> {
var response = await fetch('https://api.weather.gov/alerts/active?zone=MIZ078');
var response = await fetch('https://api.weather.gov/alerts/active?point=41.76760,-86.17275');
var data = await response.json();
return new WeatherAlerts(data);
}

0 comments on commit 2594d91

Please sign in to comment.