Skip to content

Commit

Permalink
Merge pull request CityOfPhiladelphia#28 from CityOfPhiladelphia/bug/…
Browse files Browse the repository at this point in the history
…tz-issues

Bug/tz issues
  • Loading branch information
ajrothwell authored Oct 1, 2024
2 parents 548fe7f + f3a8ea8 commit 81ff7ec
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev_push_to_s3_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: dev Push to S3 dev bucket
on:
push:
branches:
- routing-changes
- bug/tz-issues
jobs:
build:

Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"accounting": "^0.4.1",
"axios": "^1.6.8",
"date-fns": "^3.6.0",
"date-fns-tz": "^3.2.0",
"maplibre-gl": "^4.1.3",
"pinia": "^2.1.7",
"proj4": "^2.11.0",
Expand Down
17 changes: 8 additions & 9 deletions src/components/topics/Voting.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup>
import { parseISO, format, fromUnixTime } from 'date-fns';
import { TZDate } from '@date-fns/tz';
import { formatInTimeZone } from 'date-fns-tz';
import useTransforms from '@/composables/useTransforms';
const { nth, phoneNumber, titleCase } = useTransforms();
Expand Down Expand Up @@ -192,13 +191,13 @@ const electionTypes = {
const electionDate = computed(() => {
if (electionSplit.value) {
if (import.meta.env.VITE_VOTING_DATA_SOURCE === 'carto') {
// return parseISO(electionSplit.value[fieldNames.election_date]);
return format(new TZDate(electionSplit.value[fieldNames.election_date], 'EST').toString(), 'MMMM d, yyyy');
// return format(parseISO(electionSplit.value[fieldNames.election_date]), 'MMMM d, yyyy');
} else if (import.meta.env.VITE_VOTING_DATA_SOURCE === 'arcgis') {
return format(fromUnixTime(electionSplit.value[fieldNames.election_date]/1000), 'MMMM d, yyyy');
}
return formatInTimeZone(electionSplit.value[fieldNames.election_date], 'America/New_York', 'MMMM d, yyyy');
// if (import.meta.env.VITE_VOTING_DATA_SOURCE === 'carto') {
// if (import.meta.env.VITE_DEBUG == 'true') console.log('typeof electionSplit.value[fieldNames.election_date]:', typeof electionSplit.value[fieldNames.election_date]);
// return formatInTimeZone(electionSplit.value[fieldNames.election_date], 'America/New_York', 'MMMM d, yyyy');
// } else if (import.meta.env.VITE_VOTING_DATA_SOURCE === 'arcgis') {
// return formatInTimeZone(electionSplit.value[fieldNames.election_date], 'America/New_York', 'MMMM d, yyyy');
// }
}
});
Expand Down
16 changes: 8 additions & 8 deletions src/composables/useTransforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// composable functions as needed

import accounting from 'accounting';
import { format, parseISO } from 'date-fns';
import { UTCDate } from '@date-fns/utc';
import { formatInTimeZone } from 'date-fns-tz';
// import { format, parseISO } from 'date-fns';

accounting.settings.currency.precision = 0;

Expand All @@ -16,12 +16,12 @@ export default function useTransforms() {
if (!value) return;
let valueTransformed;
if (import.meta.env.VITE_DEBUG == 'true') console.log('date transform running, value:', value, 'typeof value:', typeof value);
if (typeof value === 'string') {
console.log('date transform parseISO(value):', parseISO(value));
valueTransformed = format(parseISO(value), 'MM/dd/yyyy');
} else {
valueTransformed = format(value, 'MM/dd/yyyy');
}
// if (typeof value === 'string') {
// console.log('date transform parseISO(value):', parseISO(value));
valueTransformed = formatInTimeZone(value, 'America/New_York', 'MM/dd/yyyy');
// } else {
// valueTransformed = formatInTimeZone(value, 'America/New_York', 'MM/dd/yyyy');
// }
return valueTransformed;
}

Expand Down

0 comments on commit 81ff7ec

Please sign in to comment.