mirror of
https://github.com/mue/mue.git
synced 2026-07-28 11:11:08 +02:00
Cleanup
This commit is contained in:
@@ -10,19 +10,22 @@ export default class Greeting extends React.Component {
|
||||
}
|
||||
|
||||
getGreeting() {
|
||||
// Get current info
|
||||
const t = new Date(); // Current date
|
||||
const h = t.getHours(); // Current hour
|
||||
const t = new Date(); // Current date object
|
||||
|
||||
// Normal
|
||||
let g = 'Good evening'; // Set the default time string to "Good evening"
|
||||
if (h < 12) g = 'Good morning'; // If it's before 12am, set the time string to "Good morning"
|
||||
else if (h < 18) g = 'Good afternoon'; // If it's before 6pm, set the time string to "Good afternoon"
|
||||
const h = t.getHours(); // Current hour
|
||||
|
||||
let g = 'Good evening'; // Set the default greeting string to "Good evening"
|
||||
if (h < 12) g = 'Good morning'; // If it's before 12am, set the greeting string to "Good morning"
|
||||
else if (h < 18) g = 'Good afternoon'; // If it's before 6pm, set the greeting string to "Good afternoon"
|
||||
|
||||
// Events
|
||||
if (t.getMonth() === 0 && t.getDate() === 1) g = 'Happy new year'; // If the date is January 1st, set it to new year
|
||||
else if (t.getMonth() === 11 && t.getDate() === 25) g = 'Merry Christmas'; // If it's December 25th, set it to xmas
|
||||
else if (t.getMonth() === 9 && t.getDate() === 31) g = 'Happy Halloween'; // If it's October 31st, set it to halloween
|
||||
const m = t.getMonth(); // Current month
|
||||
const d = t.getDate(); // Current Date
|
||||
|
||||
if (m === 0 && d === 1) g = 'Happy new year'; // If the date is January 1st, set the greeting string to "Happy new year"
|
||||
else if (m === 11 && d === 25) g = 'Merry Christmas'; // If it's December 25th, set the greeting string to "Merry Christmas"
|
||||
else if (m === 9 && d === 31) g = 'Happy Halloween'; // If it's October 31st, set the greeting string to "Happy Halloween"
|
||||
|
||||
this.setState({
|
||||
greeting: g
|
||||
|
||||
Reference in New Issue
Block a user