-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #614 from scarf005/feat-custom-date-format
feat: customizable date format
- Loading branch information
Showing
4 changed files
with
18 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,8 @@ You can specify configuration options either via a config file (default: `config | |
| `app.heartbeat_max_age /`<br>`WAKAPI_HEARTBEAT_MAX_AGE` | `4320h` | Maximum acceptable age of a heartbeat (see [`ParseDuration`](https://pkg.go.dev/time#ParseDuration)) | | ||
| `app.custom_languages` | - | Map from file endings to language names | | ||
| `app.avatar_url_template` /<br>`WAKAPI_AVATAR_URL_TEMPLATE` | (see [`config.default.yml`](config.default.yml)) | URL template for external user avatar images (e.g. from [Dicebear](https://dicebear.com) or [Gravatar](https://gravatar.com)) | | ||
| `app.date_format` /<br>`WAKAPI_DATE_FORMAT` | `Mon, 02 Jan 2006` | Go time format strings to format human-readable date (see [`Time.Format`](https://pkg.go.dev/time#Time.Format)) | | ||
| `app.datetime_format` /<br>`WAKAPI_DATETIME_FORMAT` | `Mon, 02 Jan 2006 15:04` | Go time format strings to format human-readable datetime (see [`Time.Format`](https://pkg.go.dev/time#Time.Format)) | | ||
| `app.support_contact` /<br>`WAKAPI_SUPPORT_CONTACT` | `[email protected]` | E-Mail address to display as a support contact on the page | | ||
| `app.data_retention_months` /<br>`WAKAPI_DATA_RETENTION_MONTHS` | `-1` | Maximum retention period in months for user data (heartbeats) (-1 for unlimited) | | ||
| `server.port` /<br> `WAKAPI_PORT` | `3000` | Port to listen on | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,6 +95,8 @@ type appConfig struct { | |
DataCleanupDryRun bool `yaml:"data_cleanup_dry_run" default:"false" env:"WAKAPI_DATA_CLEANUP_DRY_RUN"` // for debugging only | ||
AvatarURLTemplate string `yaml:"avatar_url_template" default:"api/avatar/{username_hash}.svg" env:"WAKAPI_AVATAR_URL_TEMPLATE"` | ||
SupportContact string `yaml:"support_contact" default:"[email protected]" env:"WAKAPI_SUPPORT_CONTACT"` | ||
DateFormat string `yaml:"date_format" default:"Mon, 02 Jan 2006" env:"WAKAPI_DATE_FORMAT"` | ||
DateTimeFormat string `yaml:"datetime_format" default:"Mon, 02 Jan 2006 15:04" env:"WAKAPI_DATETIME_FORMAT"` | ||
CustomLanguages map[string]string `yaml:"custom_languages"` | ||
Colors map[string]map[string]string `yaml:"-"` | ||
} | ||
|
@@ -482,6 +484,12 @@ func Load(configFlag string, version string) *Config { | |
if config.Security.TrustedHeaderAuth && len(config.Security.trustReverseProxyIpParsed) == 0 { | ||
config.Security.TrustedHeaderAuth = false | ||
} | ||
if _, err := time.Parse(config.App.DateFormat, "2006-01-02"); err != nil { | ||
logbuch.Fatal("invalid date format '%s'", config.App.DateFormat) | ||
} | ||
if _, err := time.Parse(config.App.DateTimeFormat, "2006-01-02 15:04"); err != nil { | ||
logbuch.Fatal("invalid datetime format '%s'", config.App.DateTimeFormat) | ||
} | ||
|
||
cronParser := cron.NewParser(cron.Second | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters