Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vite branch to current state of dev before merge #1609

Merged
merged 9 commits into from
Mar 5, 2024
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
Loading