fixed up handling of timestamps for database and profile display

This commit is contained in:
2025-10-13 15:54:04 -06:00
parent 55f5cc5eca
commit ed10c83b01
4 changed files with 18 additions and 7 deletions
+11 -1
View File
@@ -87,6 +87,16 @@ func (p *UserPrefs) MessagePrinter() *message.Printer {
return message.NewPrinter(*p.LanguageTag())
}
// Location returns the time.Location for these user prefs.
func (p *UserPrefs) Location() *time.Location {
rc, err := time.LoadLocation(p.TimeZoneID)
if err != nil {
log.Fatalf("BOGUS TIMEZONE TAG %s in user prefs for uid %d", p.TimeZoneID, p.Uid)
return time.Local
}
return rc
}
// User represents a user in the Amsterdam database.
type User struct {
Mutex sync.RWMutex
@@ -613,7 +623,7 @@ func AmCreateNewUser(username string, password string, reminder string, dob *tim
// Insert the user record.
_, err2 := amdb.Exec(`INSERT INTO users (username, passhash, verify_email, lockout, email_confnum,
base_lvl, created, lastaccess, passreminder, description, dob) VALUES (?, ?, 0, 0, ?, ?, UTC_TIMESTAMP(), UTC_TIMESTAMP(), ?, '', ?)`,
base_lvl, created, lastaccess, passreminder, description, dob) VALUES (?, ?, 0, 0, ?, ?, NOW(), NOW(), ?, '', ?)`,
username, hashPassword(password), util.GenerateRandomConfirmationNumber(), AmDefaultRole("Global.NewUser").Level(),
reminder, dob)
if err2 != nil {