Skip to content

Commit

Permalink
Update favicon per RFG. Fix DST bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtheletter committed Mar 12, 2018
1 parent d836c23 commit 12a1228
Show file tree
Hide file tree
Showing 48 changed files with 128 additions and 1,411 deletions.
Binary file added android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png?v=kPxzkAPK08"/>
<TileColor>#777777</TileColor>
</tile>
</msapplication>
</browserconfig>
File renamed without changes
Binary file added dateclock-logo-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dateclock-logo-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions dateclock.css
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ input {
.display-digital {
background-color: #000;
display: inline-block;
font-size: 6.7vw;
font-size: 7vw;
font-weight: 300;
margin: 0 auto;
padding: 3vw 8.25vw;
padding: 1.25vw 6.75vw;
transition: background-color 0.25s;
}
#toggle-theme:checked ~ .display-digital {
Expand Down
83 changes: 43 additions & 40 deletions dateclock.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,30 +123,33 @@
return new Date(datetime.getFullYear(), datetime.getMonth() + 1, 0).getDate();
}
function getHoursInDst (datetime) {
var januaryOffsetHours = new Date(datetime.getFullYear(), 0, 1).getTimezoneOffset() / 60;
var julyOffsetHours = new Date(datetime.getFullYear(), 6, 1).getTimezoneOffset() / 60;
var januaryOffsetHours = new Date(datetime.getFullYear(), 0, 1).getTimezoneOffset() * -1 / 60;
var julyOffsetHours = new Date(datetime.getFullYear(), 6, 1).getTimezoneOffset() * -1 / 60;
return Math.abs(januaryOffsetHours - julyOffsetHours);
}
function isDstExpected (datetime) {
var currentOffsetHours = datetime.getTimezoneOffset() / 60; // 8
return hoursInDst - currentOffsetHours === 0;
}
function setOffset (datetime) {
var offset = datetime.getTimezoneOffset() / 60;
if (isDstExpected(datetime) && !els.toggleTime.checked) { // If DST is expected, but user does not want it...
offset += hoursInDst;
} else if (!isDstExpected(datetime) && els.toggleTime.checked) { // If DST is not expected, but user wants it...
offset -= hoursInDst;
function doesLocaleObserveDstOnDate (datetime) {
var januaryOffsetHours = new Date(datetime.getFullYear(), 0, 1).getTimezoneOffset() * -1 / 60; // -8 Los Angeles (ST). +1 Berlin (ST). +11 Sydney (DST). -3 Santiago (DST).
var julyOffsetHours = new Date(datetime.getFullYear(), 6, 1).getTimezoneOffset() * -1 / 60; // -7 Los Angeles (DST). +2 Berlin (DST). +10 Sydney (ST). -4 Santiago (ST).
var standardOffsetHours = Math.min(januaryOffsetHours, julyOffsetHours);
var datetimeOffsetHours = datetime.getTimezoneOffset() * -1 / 60;
return datetimeOffsetHours !== standardOffsetHours;
}
function setClockOffset (datetime) {
var offsetHours = datetime.getTimezoneOffset() * -1 / 60;
if (doesLocaleObserveDstOnDate(datetime) && !els.toggleTime.checked) { // If locale is observing DST, but user does not want it...
offsetHours -= hoursInDst;
} else if (!doesLocaleObserveDstOnDate(datetime) && els.toggleTime.checked) { // If locale isn't observing DST, but user wants it...
offsetHours += hoursInDst;
}
if (offset > 0) {
els.utcOffset.textContent = `UTC\u002d${offset}h`; // hyphen-minus sign
} else if (offset < 0) {
els.utcOffset.textContent = `UTC\u002b${offset}h`; // plus sign
if (offsetHours < 0) {
els.utcOffset.textContent = `UTC\u002d${Math.abs(offsetHours)}h`; // hyphen-minus sign
} else if (offsetHours > 0) {
els.utcOffset.textContent = `UTC\u002b${offsetHours}h`; // plus sign
} else {
els.utcOffset.textContent = `UTC\u00b1${offset}h`; // plus-minus sign
els.utcOffset.textContent = `UTC\u00b10h`; // plus-minus sign
}
}
function setMonth (datetime) {
function setClockMonth (datetime) {
var month = datetime.getMonth() + 1; // Add one month for natural counting.
var day = datetime.getDate();
var daysInMonth = getDaysInMonth(datetime);
Expand All @@ -156,51 +159,51 @@
if (daysInMonth !== numberOfDayPips) { // Update pips for days of month, if total days changes.
drawPipDay(datetime);
}
setOffset(datetime); // Update offset.
setClockOffset(datetime); // Update offset.
}
function setDay (datetime) {
function setClockDay (datetime) {
var day = datetime.getDate();
var hour = datetime.getHours();
var daysInMonth = getDaysInMonth(datetime);
var degs = (day - 1 + hour / 24) / daysInMonth * 360; // Subtract one day for zero indexing.
rotate(els.handDay, degs);
els.digitDay.textContent = day < 10 ? `0${day}` : day;
setMonth(datetime); // Update month.
setClockMonth(datetime); // Update month.
}
function setHour (datetime) {
function setClockHour (datetime) {
var hour = datetime.getHours();
var minute = datetime.getMinutes();
var degs = (hour + minute / 60) / 24 * 360;
rotate(els.handHour, degs);
els.digitHour.textContent = hour < 10 ? `0${hour}` : hour;
setDay(datetime); // Update day.
prevSetHourDatetime = datetime;
setClockDay(datetime); // Update day.
prevSetClockHourDatetime = datetime;
}
function setMinute (datetime) {
function setClockMinute (datetime) {
var minute = datetime.getMinutes();
var second = datetime.getSeconds();
var degs = (minute + second / 60) / 60 * 360;
rotate(els.handMinute, degs);
els.digitMinute.textContent = minute < 10 ? `0${minute}` : minute;
if (second === 0 || datetime - prevSetHourDatetime > 1000 * 60) { // Update hour (& day, month, offset) on whole minute or after one minute.
setHour(datetime);
if (second === 0 || datetime - prevSetClockHourDatetime > 1000 * 60) { // Update hour (& day, month, offset) on whole minute or after one minute.
setClockHour(datetime);
}
prevSetMinuteDatetime = datetime;
prevSetClockMinuteDatetime = datetime;
}
function setSecond (datetime) { // Set seconds. Set larger units as needed.
function setClockSecond (datetime) { // Set seconds. Set larger units as needed.
datetime = datetime || new Date(); // Invocations by setInterval use new Date objects.
if (isDstExpected(datetime) && !els.toggleTime.checked) { // If DST is expected, but user does not want it...
if (doesLocaleObserveDstOnDate(datetime) && !els.toggleTime.checked) { // If local is observing DST, but user does not want it...
datetime = new Date(datetime.valueOf() - hoursInDst * 60 * 60 * 1000);
} else if (!isDstExpected(datetime) && els.toggleTime.checked) { // If DST is not expected, but user wants it...
} else if (!doesLocaleObserveDstOnDate(datetime) && els.toggleTime.checked) { // If local isn't observing DST, but user wants it...
datetime = new Date(datetime.valueOf() + hoursInDst * 60 * 60 * 1000);
}
var second = datetime.getSeconds();
var millisecond = datetime.getMilliseconds();
var degs = (second + millisecond / 1000) / 60 * 360;
rotate(els.handSecond, degs);
els.digitSecond.textContent = second < 10 ? `0${second}` : second;
if (millisecond === 0 || datetime - prevSetMinuteDatetime > 1000) { // Update minute on whole seconds or after one second.
setMinute(datetime);
if (millisecond === 0 || datetime - prevSetClockMinuteDatetime > 1000) { // Update minute on whole seconds or after one second.
setClockMinute(datetime);
}
}
function getElements () {
Expand Down Expand Up @@ -301,8 +304,8 @@

// Trigger datetime re-calculations when user toggles DST/ST.
els.toggleLabelTime.addEventListener('click', function () {
prevSetHourDatetime = 0;
prevSetMinuteDatetime = 0;
prevSetClockHourDatetime = 0;
prevSetClockMinuteDatetime = 0;
});

// Save user prefs for all toggles to local storage.
Expand Down Expand Up @@ -357,8 +360,8 @@
var datetime = new Date();
// datetime = new Date(1970, 10 - 1, 7, 9, 35, 18); // "Factory Display"

var prevSetHourDatetime = 0;
var prevSetMinuteDatetime = 0;
var prevSetClockHourDatetime = 0;
var prevSetClockMinuteDatetime = 0;

var numberOfDayPips = getDaysInMonth(datetime);
var hoursInDst = getHoursInDst(datetime) || 1; // Default one if no DST for locale.
Expand Down Expand Up @@ -400,7 +403,7 @@
if (userPrefTime !== null) {
els.toggleTime.checked = userPrefTime;
} else {
els.toggleTime.checked = isDstExpected(datetime); // Use local DST expectation if no user pref stored.
els.toggleTime.checked = doesLocaleObserveDstOnDate(datetime); // Use locale's DST observation if no user pref stored.
}
if (userPrefOrientation !== null) {
els.toggleOrientation.checked = userPrefOrientation;
Expand All @@ -413,9 +416,9 @@
els.toggleTheme.checked = true;
}

setSecond(datetime);
setClockSecond(datetime);
els.fg.classList.remove('closed');
setInterval(setSecond, 40); // Arbitray rate that looks good enough onscreen.
setInterval(setClockSecond, 40); // Arbitray rate that looks good enough onscreen.

// Demo highlights for new user.
if (!userHasHighlighted) {
Expand Down
Binary file removed favicomatic/apple-touch-icon-114x114.png
Binary file not shown.
Binary file removed favicomatic/apple-touch-icon-120x120.png
Binary file not shown.
Binary file removed favicomatic/apple-touch-icon-144x144.png
Binary file not shown.
Binary file removed favicomatic/apple-touch-icon-152x152.png
Binary file not shown.
Binary file removed favicomatic/apple-touch-icon-57x57.png
Binary file not shown.
Binary file removed favicomatic/apple-touch-icon-60x60.png
Binary file not shown.
Binary file removed favicomatic/apple-touch-icon-72x72.png
Binary file not shown.
Binary file removed favicomatic/apple-touch-icon-76x76.png
Binary file not shown.
20 changes: 0 additions & 20 deletions favicomatic/code.txt

This file was deleted.

Binary file removed favicomatic/favicon-128.png
Binary file not shown.
Binary file removed favicomatic/favicon-16x16.png
Binary file not shown.
Binary file removed favicomatic/favicon-196x196.png
Binary file not shown.
Binary file removed favicomatic/favicon-32x32.png
Binary file not shown.
Binary file removed favicomatic/favicon-96x96.png
Binary file not shown.
Binary file removed favicomatic/favicon.ico
Binary file not shown.
Binary file removed favicomatic/mstile-144x144.png
Binary file not shown.
Binary file removed favicomatic/mstile-150x150.png
Binary file not shown.
Binary file removed favicomatic/mstile-310x150.png
Binary file not shown.
Binary file removed favicomatic/mstile-310x310.png
Binary file not shown.
Binary file removed favicomatic/mstile-70x70.png
Binary file not shown.
Binary file added favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon-32x32.png
Loading

0 comments on commit 12a1228

Please sign in to comment.