Skip to content

Commit

Permalink
Merge pull request #9 from yacosta738/development
Browse files Browse the repository at this point in the history
v3.1 fixed date issue reported in dev challenge.
  • Loading branch information
yacosta738 authored May 26, 2021
2 parents e0806e1 + c4ffe19 commit 16aef9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/components/WeatherGeneralPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ import {Options, Vue} from 'vue-class-component';
import {WeatherData} from "../models/weather-data.model";
import {Weather} from "../models/weather.model";
import {celsiusToFahrenheit, isToday, isTomorrow, weatherStateImage} from "../utilities/util";
import {celsiusToFahrenheit, isTomorrow, weatherStateImage} from "../utilities/util";
import {format} from "date-fns";
import CardSkeletonLoader from "./CardSkeletonLoader.vue";
Expand All @@ -133,8 +133,12 @@ import CardSkeletonLoader from "./CardSkeletonLoader.vue";
export default class WeatherGeneralPanel extends Vue {
weatherDate(applicableDate: string | Date, index: number) {
const date = applicableDate ? new Date(applicableDate) : new Date();
return isTomorrow(date) || index === 0? 'Tomorrow' : format(date, 'E, d MMM');
const date: Date = applicableDate ?
typeof applicableDate === 'string' ?
new Date(Date.parse(applicableDate))
: applicableDate
: new Date();
return isTomorrow(date) || index === 0 ? 'Tomorrow' : format(date, 'E, d MMM');
}
get todayWeather() {
Expand Down
2 changes: 1 addition & 1 deletion src/models/weather.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class Weather implements IWeather {
return json
? new Weather(
json.air_pressure,
json.applicable_date.includes('-')? json.applicable_date.replace('-', '/'):json.applicable_date,
json.applicable_date,
json.created,
json.humidity,
json.id,
Expand Down

1 comment on commit 16aef9a

@vercel
Copy link

@vercel vercel bot commented on 16aef9a May 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.