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

Dashboard greetings shows goodmorning while it is after 12:00 (24h) #24938

Closed
radoeka opened this issue Jan 2, 2021 · 9 comments · Fixed by #24970
Closed

Dashboard greetings shows goodmorning while it is after 12:00 (24h) #24938

radoeka opened this issue Jan 2, 2021 · 9 comments · Fixed by #24970
Labels
1. to develop Accepted and waiting to be taken care of bug good first issue Small tasks with clear documentation about how and in which place you need to fix things in.

Comments

@radoeka
Copy link

radoeka commented Jan 2, 2021

Steps to reproduce

  1. Visit Nextcloud Dashboard, after 12:00 (24H) https:///apps/dashboard/#/

Expected behaviour

The greeting should be Good Afternoon.

Actual behaviour

The greeting shows Good morning

See https://help.nextcloud.com/t/dashboard-time-incorrect/101461 as well.

Server configuration

Operating system: openSUSE_15.2

Web server: Apache

Database: SQLite

PHP version: 7.4.6

Nextcloud version: (see Nextcloud admin page) 20.0.4

Updated from an older Nextcloud/ownCloud or fresh install: older

Where did you install Nextcloud from: Nextcloud

Client configuration

Browser: Chromium

Operating system: windows / linux

@radoeka radoeka added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Jan 2, 2021
@kesselb
Copy link
Contributor

kesselb commented Jan 2, 2021

See https://help.nextcloud.com/t/dashboard-time-incorrect/101461 as well.

I don't see how this post is related to your bug report.

The greeting shows Good morning

greeting() {
const time = this.timer.getHours()
const shouldShowName = this.displayName && this.uid !== this.displayName
if (time > 18) {
return { text: shouldShowName ? t('dashboard', 'Good evening, {name}', { name: this.displayName }) : t('dashboard', 'Good evening') }
}
if (time > 12) {
return { text: shouldShowName ? t('dashboard', 'Good afternoon, {name}', { name: this.displayName }) : t('dashboard', 'Good afternoon') }
}
if (time > 5) {
return { text: shouldShowName ? t('dashboard', 'Good morning, {name}', { name: this.displayName }) : t('dashboard', 'Good morning') }
}
return { text: shouldShowName ? t('dashboard', 'Good night, {name}', { name: this.displayName }) : t('dashboard', 'Good night') }
},

Above code generates the greeting text. this.timer is initialized earlier like this.timer = new Date(). The information provided by your browser are used to generated the text.

You may use the browser's developers tool (F12) to debug the issue. (new Date()).getHours(); for example is the value for time in line 165 above. If your browser is reporting a weird value that's nothing we can fix.

@radoeka
Copy link
Author

radoeka commented Jan 2, 2021

Thanks for your reference to the code (and including it).

The code shows:

			if (time > 12) {
				return { text: shouldShowName ? t('dashboard', 'Good afternoon, {name}', { name: this.displayName }) : t('dashboard', 'Good afternoon') }
			}

That should be "time >= 12" at least for 24H time notation (and that is what is used in most countries in the world except 3).

The afternoon start after 12:00.
The same can be said about the night. It starts after 18:00, so the code should contain "time => 18" instead of "time > 18".

This seems fixable.

@kesselb kesselb added 1. to develop Accepted and waiting to be taken care of good first issue Small tasks with clear documentation about how and in which place you need to fix things in. and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap needs info labels Jan 2, 2021
@kesselb
Copy link
Contributor

kesselb commented Jan 2, 2021

Sounds good to me. I guess there are not strict rules. Mind to sent a patch with your suggested time ranges?

Afternoon is from 19 to 0 at the moment. I think that's also a bit unusual (at least in Germany). Night is usually from 22 to 6.

@radoeka
Copy link
Author

radoeka commented Jan 2, 2021

Mind to sent a patch with your suggested time ranges?
Find the patch below. I've no possibility to create a pull request.

Night is usually from 22 to 6.
Made it from 23 - 5 (at 5 o'clock I'm rather greeted with good morning, then good night. The end time could even be at 4:00)

It seems that it is not possible to attached a file :(

The times are now according the following table:
0 Night
5 Morning
13 Afternoon
19 Evening
23 Night

$ cat App.vue.txt.diff
--- a/App.vue.txt       2021-01-02 21:37:05.412092500 +0100
+++ b/App.vue.txt       2021-01-02 21:49:10.707478300 +0100
@@ -165,13 +165,16 @@
                        const time = this.timer.getHours()
                        const shouldShowName = this.displayName && this.uid !== this.displayName

-                       if (time > 18) {
+                       if (time >= 23) {
+                               return { text: shouldShowName ? t('dashboard', 'Good night, {name}', { name: this.displayName }) : t('dashboard', 'Good night') }
+                       }
+                       if (time >= 18) {
                                return { text: shouldShowName ? t('dashboard', 'Good evening, {name}', { name: this.displayName }) : t('dashboard', 'Good evening') }
                        }
-                       if (time > 12) {
+                       if (time >= 12) {
                                return { text: shouldShowName ? t('dashboard', 'Good afternoon, {name}', { name: this.displayName }) : t('dashboard', 'Good afternoon') }
                        }
-                       if (time > 5) {
+                       if (time >= 5) {
                                return { text: shouldShowName ? t('dashboard', 'Good morning, {name}', { name: this.displayName }) : t('dashboard', 'Good morning') }
                        }
                        return { text: shouldShowName ? t('dashboard', 'Good night, {name}', { name: this.displayName }) : t('dashboard', 'Good night') }

There are tabs in the code :( that makes it hard to provide a simple patch. All the lines start with tabs:

--- a/App.vue.txt^I2021-01-02 21:37:05.412092500 +0100
+++ b/App.vue.txt^I2021-01-02 21:49:10.707478300 +0100
@@ -165,13 +165,16 @@
 ^I^I^Iconst time = this.timer.getHours()
 ^I^I^Iconst shouldShowName = this.displayName && this.uid !== this.displayName

-^I^I^Iif (time > 18) {
+^I^I^Iif (time >= 23) {
+^I^I^I^Ireturn { text: shouldShowName ? t('dashboard', 'Good night, {name}', { name: this.displayName }) : t('dashboard', 'Good night') }
+^I^I^I}
+^I^I^Iif (time >= 18) {
 ^I^I^I^Ireturn { text: shouldShowName ? t('dashboard', 'Good evening, {name}', { name: this.displayName }) : t('dashboard', 'Good evening') }
 ^I^I^I}
-^I^I^Iif (time > 12) {
+^I^I^Iif (time >= 12) {
 ^I^I^I^Ireturn { text: shouldShowName ? t('dashboard', 'Good afternoon, {name}', { name: this.displayName }) : t('dashboard', 'Good afternoon') }
 ^I^I^I}
-^I^I^Iif (time > 5) {
+^I^I^Iif (time >= 5) {
 ^I^I^I^Ireturn { text: shouldShowName ? t('dashboard', 'Good morning, {name}', { name: this.displayName }) : t('dashboard', 'Good morning') }
 ^I^I^I}
 ^I^I^Ireturn { text: shouldShowName ? t('dashboard', 'Good night, {name}', { name: this.displayName }) : t('dashboard', 'Good night') }

@nina-py
Copy link
Contributor

nina-py commented Jan 5, 2021

I've no possibility to create a pull request.

@radoeka, I could do it for you if you like?

Sounds good to me. I guess there are not strict rules.

@kesselb, yes the rules are not very strict but there is some variance - I was surprised to discover, after a quick google search, that for some people evening starts at 5 pm (17:00) and night - at 8 pm (20:00).

One thing to note is that "Good night" is not normally used as a greeting in English, it is a way of saying goodbye instead: https://english.stackexchange.com/questions/100870/what-is-an-appropriate-greeting-to-use-at-night-time. Some suggestions from that link are "Greetings, night owl" (which sounds very dawn-of-the-internet to me), using "Good evening" up to midnight and beyond or the universal "Hello!".

@jancborchardt
Copy link
Member

Yep, @radoeka’s improvements on the time are good.

@nina-py go ahead if you can open a pull request, that would be cool! Also feel free to take out the "Good night" part as you mention. :)

@nina-py
Copy link
Contributor

nina-py commented Jan 5, 2021

@jancborchardt, done! The cut-off times in my PR are slightly different to what @radoeka suggested (i.e. evening starts at 6 pm, not 7 pm), but I'm happy to adjust to whatever you would prefer instead.

@radoeka
Copy link
Author

radoeka commented Jan 5, 2021

yes the rules are not very strict but there is some variance - I was surprised to discover

The solution for this would be to make the time configurable for the user. This way almost everybody can be happy, with get getting a good evening starting at 17:00 and others at 19:00.

@radoeka
Copy link
Author

radoeka commented Jan 5, 2021

Thanks for looking into this, and making the code nicer and better.

One more observation should there be a comma in the greeting or not?
At the moment there is a comma, however somehow the comma seems to be big, seems to use too much space....

Is it:
Hello, Joe
or should it become?
Hello Joe

From a privacy point of view it would be nice to be able to hide the name. For example when one is in a train, not everbody needs to know my name...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of bug good first issue Small tasks with clear documentation about how and in which place you need to fix things in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants