Skip to content

Commit

Permalink
Merge pull request #1609 from hackforla/development
Browse files Browse the repository at this point in the history
Update `vite` branch to current state of dev before merge
  • Loading branch information
trillium authored Mar 5, 2024
2 parents 5b5a982 + d29446f commit b9368c7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 124 deletions.
2 changes: 2 additions & 0 deletions backend/workers/createRecurringEvents.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const generateEventData = require('./lib/generateEventData');

module.exports = (cron, fetch) => {

// Check to see if any recurring events are happening today,
Expand Down
35 changes: 10 additions & 25 deletions backend/workers/lib/generateEventData.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
// grab the updatedDate
// get the timeZone offset
// if timeZone offset differs from the updatedDate to now
// normalize time to the updatedDate

function generateEventData(eventObj, TODAY_DATE = new Date()) {
/**
* Generates event data based on the provided event object and date.
* In the cron job this function normally runs in, it is expected that eventObj.date is the same as TODAY_DATE.
*/

const oldStartTime = new Date(eventObj.startTime);
const eventDate = new Date(eventObj.startTime);
// Create new event
const oldHours = oldStartTime.getHours();
const oldMinutes = oldStartTime.getMinutes();
const oldSeconds = oldStartTime.getSeconds();
const oldMilliseconds = oldStartTime.getMilliseconds();
const hours = eventDate.getHours();
const minutes = eventDate.getMinutes();
const seconds = eventDate.getSeconds();
const milliseconds = eventDate.getMilliseconds();

const newYear = TODAY_DATE.getFullYear();
const newMonth = TODAY_DATE.getMonth();
const newDate = TODAY_DATE.getDate();

const oldTz = oldStartTime.getTimezoneOffset();
const newTz = TODAY_DATE.getTimezoneOffset();
const tzDiff = oldTz - newTz;
const yearToday = TODAY_DATE.getFullYear();
const monthToday = TODAY_DATE.getMonth();
const dateToday = TODAY_DATE.getDate();

const newEventDate = new Date(newYear, newMonth, newDate, oldHours, oldMinutes, oldSeconds, oldMilliseconds);
const newEventDate = new Date(yearToday, monthToday, dateToday, hours, minutes, seconds, milliseconds);

const newEndTime = new Date(newYear, newMonth, newDate, oldHours + eventObj.hours, oldMinutes, oldSeconds, oldMilliseconds)

if (tzDiff != 0) {
newEventDate.setMinutes(newEventDate.getMinutes() + tzDiff)
newEndTime.setMinutes(newEndTime.getMinutes() + tzDiff)
}
const newEndTime = new Date(yearToday, monthToday, dateToday, hours + eventObj.hours, minutes, seconds, milliseconds)

const eventToCreate = {
name: eventObj.name && eventObj.name,
Expand Down
97 changes: 0 additions & 97 deletions backend/workers/lib/generateEventData.test.js

This file was deleted.

4 changes: 2 additions & 2 deletions client/src/components/user-admin/UserManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ const UserManagement = ({ users, setUserToEdit }) => {
</Box>
</Box>
<Box>
<Button
{/* <Button
type='button'
variant='secondary'
>
Add a New User
</Button>
</Button> */}
</Box>
</Box>
</Box>
Expand Down

0 comments on commit b9368c7

Please sign in to comment.