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

Made relativeTime text output title case to match k2 style #1112

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions ee/desktop/menu/menu_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ func (tp *templateParser) Parse(text string) (string, error) {

switch {
case diff < 60*10: // less than 10 minutes
return "very soon"
return "Very Soon"
case diff < 60*50: // less than 50 minutes
return fmt.Sprintf("in %d minutes", diff/60)
return fmt.Sprintf("In %d Minutes", diff/60)
case diff < 60*90: // less than 90 minutes
return "in about an hour"
return "In About An Hour"
case diff < 60*60*23: // less than 23 hours
return fmt.Sprintf("in %d hours", diff/3600)
return fmt.Sprintf("In %d Hours", diff/3600)
case diff < 60*60*36: // less than 36 hours
return "in one day"
return "In One Day"
case diff < 60*60*24*14: // less than 14 days
return fmt.Sprintf("in %d days", diff/86400)
return fmt.Sprintf("In %d Days", diff/86400)
default: // 2 weeks or more
return fmt.Sprintf("in %d weeks", diff/604800)
return fmt.Sprintf("In %d Weeks", diff/604800)
}
},
}).Parse(text)
Expand Down
32 changes: 16 additions & 16 deletions ee/desktop/menu/menu_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,50 +46,50 @@ func Test_Parse(t *testing.T) {
{
name: "relativeTime very soon",
td: &TemplateData{ServerHostname: "localhost", LauncherVersion: "0.0.0"},
text: fmt.Sprintf("This is starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(2*time.Minute+30*time.Second).Unix()),
output: "This is starting very soon.",
text: fmt.Sprintf("This Is Starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(2*time.Minute+30*time.Second).Unix()),
output: "This Is Starting Very Soon.",
},
{
name: "relativeTime 15 minutes",
td: &TemplateData{ServerHostname: "localhost", LauncherVersion: "0.0.0"},
text: fmt.Sprintf("This is starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(15*time.Minute+30*time.Second).Unix()),
output: "This is starting in 15 minutes.",
text: fmt.Sprintf("This Is Starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(15*time.Minute+30*time.Second).Unix()),
output: "This Is Starting In 15 Minutes.",
},
{
name: "relativeTime one hour",
td: &TemplateData{ServerHostname: "localhost", LauncherVersion: "0.0.0"},
text: fmt.Sprintf("This is starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(1*time.Hour+30*time.Second).Unix()),
output: "This is starting in about an hour.",
text: fmt.Sprintf("This Is Starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(1*time.Hour+30*time.Second).Unix()),
output: "This Is Starting In About An Hour.",
},
{
name: "relativeTime four hours",
td: &TemplateData{ServerHostname: "localhost", LauncherVersion: "0.0.0"},
text: fmt.Sprintf("This is starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(4*time.Hour+30*time.Second).Unix()),
output: "This is starting in 4 hours.",
text: fmt.Sprintf("This Is Starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(4*time.Hour+30*time.Second).Unix()),
output: "This Is Starting In 4 Hours.",
},
{
name: "relativeTime one day",
td: &TemplateData{ServerHostname: "localhost", LauncherVersion: "0.0.0"},
text: fmt.Sprintf("This is starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(24*time.Hour+30*time.Second).Unix()),
output: "This is starting in one day.",
text: fmt.Sprintf("This Is Starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(24*time.Hour+30*time.Second).Unix()),
output: "This Is Starting In One Day.",
},
{
name: "relativeTime three days",
td: &TemplateData{ServerHostname: "localhost", LauncherVersion: "0.0.0"},
text: fmt.Sprintf("This is starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(3*24*time.Hour+30*time.Second).Unix()),
output: "This is starting in 3 days.",
text: fmt.Sprintf("This Is Starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(3*24*time.Hour+30*time.Second).Unix()),
output: "This Is Starting In 3 Days.",
},
{
name: "relativeTime seven days",
td: &TemplateData{ServerHostname: "localhost", LauncherVersion: "0.0.0"},
text: fmt.Sprintf("This is starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(7*24*time.Hour+30*time.Second).Unix()),
output: "This is starting in 7 days.",
text: fmt.Sprintf("This Is Starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(7*24*time.Hour+30*time.Second).Unix()),
output: "This Is Starting In 7 Days.",
},
{
name: "relativeTime two weeks",
td: &TemplateData{ServerHostname: "localhost", LauncherVersion: "0.0.0"},
text: fmt.Sprintf("This is starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(14*24*time.Hour+30*time.Second).Unix()),
output: "This is starting in 2 weeks.",
text: fmt.Sprintf("This Is Starting {{if hasCapability \"relativeTime\"}}{{relativeTime %d}}{{else}}never{{end}}.", time.Now().Add(14*24*time.Hour+30*time.Second).Unix()),
output: "This Is Starting In 2 Weeks.",
},
{
name: "undefined",
Expand Down