-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add Support for Timezones #12
Closed
Closed
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
d3d722b
remove extraneous </html>
MoralCode c21b292
add schoolIsInSession() function
MoralCode f168fb6
add state flags
MoralCode 426c81b
remove passing periods from the schedule
MoralCode 76a8b68
re-organise updateText using state flags
MoralCode a0af5a6
continue to update the time even if schedule data is not available
MoralCode bd0c146
Add flash function
MoralCode 53d8eea
Change data structure to support multiple hardcoded schools
MoralCode 4a608cf
add function to get an index from localStorage
MoralCode 437b16d
Add School Name
MoralCode d775a8b
fix close spacing on settings page
MoralCode 5fde3c6
continue to update date and time even if a school isn't selected
MoralCode 516b99e
move nav button HTML to a more sensible place
MoralCode 2249dd7
group elements that are schedule-based together for easier hiding
MoralCode e8fec35
hide schedule-based elements when there is no schedule selected
MoralCode cfac59c
move flash messages above the whole page rather than over the top of it
MoralCode e037d9e
Documentation and cleanup
MoralCode cc3af4a
fix flashing so that the layouts dont break on mobile
MoralCode 12eedae
add school name to summary for clarity
MoralCode 5fcc0fa
add slack link instead of github issues link
MoralCode 5c2188c
Add a tracking metric for the school someone has selected
MoralCode 9cae0b8
Move "View Schedule" link
MoralCode 5cfa996
re-configure display of school name on homepage
MoralCode 359ff24
fix flash messages taking up half the screen sometimes
MoralCode a7eb69c
add tracking for usage of time display setting
MoralCode 96eadf6
refactor getClassName()
MoralCode d3a8978
replace time globals with a method to get the current time object
MoralCode 8a7fdbf
add proper time comparison methods
MoralCode 7ad2861
implement new time methods
MoralCode 8bfd994
fix centered links extending all the way across the page
MoralCode c1d7049
fix missing "...which ends in:" data on main page
MoralCode 2c66a1f
refactor compareTimes() to include minutes in it's calculation
MoralCode 2e07244
Add sanitizeTimeObject()
MoralCode f424879
add getMostRecentlyStartedClassIndex()
MoralCode 854c7ea
make getTimeDelta() more flexible
MoralCode d9878b4
samitize times before comparing them so it doesnt skip seconds
MoralCode 50a3ba1
add passing period name to school data
MoralCode 3b358a2
add getTimeTo() shortcut
MoralCode db6d769
remove getTimeToEndOfCurrentClassString() and getTimeToStartOfSchoolS…
MoralCode ce25c98
update documentation and comments
MoralCode 00893bf
replace tracking code with matomo tag manager
MoralCode 6bfbc2b
hide labels on no school days
MoralCode 6b485dd
add styles for links in flash messages
MoralCode 1f49a7a
remove links from readme
MoralCode 97e7ab5
update domain name on dev branch
MoralCode f611fc0
fix an instance of the old name
MoralCode 0ae2bd8
Update README file
MoralCode 4c37921
Add support for Timezones.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,17 +16,15 @@ var currentClassPeriodIndex = -1; | |
var currentScheduleIndex = -1; | ||
var selectedSchoolIndex = 0; | ||
|
||
|
||
var use24HourTime = getLocalStorageBoolean("use24HourTime", false); | ||
|
||
|
||
|
||
var schools = [ | ||
{ | ||
fullName: "Lake Oswego High School", | ||
shortName: "LOHS", | ||
passingPeriodName: "Passing Period", //the name to use for time gaps in the schedule between classes | ||
//order is as is on the school website, although it doesnt matter. | ||
timeZone: 'America/Los_Angeles', | ||
schedules: [ | ||
{ | ||
name: "Mon/Fri (Regular)", | ||
|
@@ -305,23 +303,29 @@ function isNoSchoolDay() { | |
/** | ||
* This function updates the variables that keep track of the current time and date | ||
*/ | ||
function updateTime() { currentDate = new Date();} | ||
function updateTime() { | ||
if (typeof selectedSchoolIndex !== 'undefined') { | ||
currentDate = moment().tz(schools[selectedSchoolIndex].timeZone); | ||
} else { | ||
currentDate = moment() | ||
} | ||
} | ||
|
||
function getCurrentTimeObject() { | ||
return {hours: currentDate.getHours(), minutes: currentDate.getMinutes(), seconds: currentDate.getSeconds()} | ||
return {hours: currentDate.hour(), minutes: currentDate.minute(), seconds: currentDate.second()} | ||
} | ||
|
||
|
||
/** | ||
* @returns the current time as a formatted string | ||
*/ | ||
function getCurrentTimeString() { return currentDate.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: !use24HourTime }) } | ||
function getCurrentTimeString() { return use24HourTime ? currentDate.format("h:mm:ss a") : currentDate.format("H:mm:ss") } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you have the 12 and 24 hour conditions reversed here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, i think AM/PM should be capitalized |
||
|
||
/** | ||
* @returns the current date as a formatted string | ||
*/ | ||
function getCurrentDateString() { | ||
return "on <strong>" + currentDate.toLocaleString('en-US', { weekday: 'short', month: 'short', day: 'numeric', year: 'numeric' }) + "</strong>" | ||
return "on <strong>" + currentDate.format("ddd, MMM Do, YYYY") + "</strong>" | ||
} | ||
|
||
/** | ||
|
@@ -389,7 +393,7 @@ function getMostRecentlyStartedClassIndex() { | |
function getCurrentScheduleIndex() { | ||
//using for over forEach() because we are breaking out of the loop early | ||
for (let i = 0; i < schools[selectedSchoolIndex].schedules.length; i++) { | ||
if (schools[selectedSchoolIndex].schedules[i].days.includes(currentDate.getDay())) { | ||
if (schools[selectedSchoolIndex].schedules[i].days.includes(currentDate.day())) { | ||
return i | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the updateTime() method is intended for updating the time in general (i.e. for the local time clock). I think it would be better to use moment to convert to and from GMT when storing and retrieving the times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, if i'm understanding this correctly, I think this might show the local time at the school instead of the users local time if there is a school selected