Skip to content

Commit

Permalink
Minor fix of clock emoji display
Browse files Browse the repository at this point in the history
Now the function will always return the correct emoji
  • Loading branch information
plasmabit committed Aug 30, 2023
1 parent 5439b43 commit a561307
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,15 @@ export default class TimeThings extends Plugin {
getClockEmojiForHour(time: moment.Moment): string {
const hour = time.hour();
const hour12 = (hour % 12) || 12;
const clockEmojis = [
'🕛', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚'
];

if (hour12 >= 0 && hour12 <= 11) {
return clockEmojis[hour12];
} else {
return '⏰'; // Default emoji for unknown hours
}

const clockEmojiMapping = {
1: '🕐', 2: '🕑', 3: '🕒', 4: '🕓', 5: '🕔', 6: '🕕',
7: '🕖', 8: '🕗', 9: '🕘', 10: '🕙', 11: '🕚', 12: '🕛'
};

return clockEmojiMapping[hour12] || '⏰'; // Default emoji for unknown hours
}


onunload() {

Expand Down Expand Up @@ -169,7 +168,7 @@ class TimeThingsSettingsTab extends PluginSettingTab {
}

containerEl.createEl('h1', { text: 'Status bar' });
containerEl.createEl('p', { text: 'Displays clock in the status bar' });
containerEl.createEl('p', { text: 'Displays clock in the status bar.' });

new Setting(containerEl)
.setName('Enable status bar clock')
Expand Down

0 comments on commit a561307

Please sign in to comment.