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
+2 -2
View File
@@ -120,7 +120,7 @@ func (ci *ContactInfo) Save() (bool, error) {
_, err := amdb.NamedExec(`UPDATE contacts SET given_name = :given_name, family_name = :family_name, middle_init = :middle_init,
prefix = :prefix, suffix = :suffix, company = :company, addr1 = :addr1, addr2 = :addr2, locality = :locality, region = :region,
pcode = :pcode, country = :country, phone = :phone, fax = :fax, mobile = :mobile, email = :email, pvt_addr = :pvt_addr,
pvt_phone = :pvt_phone, pvt_fax = :pvt_fax, pvt_email = :pvt_email, photo_url = :photo_url, url = :url, lastupdate = UTC_TIMESTAMP()
pvt_phone = :pvt_phone, pvt_fax = :pvt_fax, pvt_email = :pvt_email, photo_url = :photo_url, url = :url, lastupdate = NOW()
WHERE contactid = :contactid`, ci)
if err != nil {
return false, err
@@ -132,7 +132,7 @@ func (ci *ContactInfo) Save() (bool, error) {
pvt_email, owner_uid, owner_commid, photo_url, url, lastupdate)
VALUES (:given_name, :family_name, :middle_init, :prefix, :suffix, :company, :addr1, :addr2, :locality,
:region, :pcode, :country, :phone, :fax, :mobile, :email, :pvt_addr, :pvt_phone, :pvt_fax, :pvt_email,
:owner_uid, :owner_commid, :photo_url, :url, UTC_TIMESTAMP())`, ci)
:owner_uid, :owner_commid, :photo_url, :url, NOW())`, ci)
if err != nil {
return false, err
}
+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 {