Beispiel #1
0
func (c ColumnElem) InLocation(loc *time.Location) ColumnElem {
	c.inner = BinaryClause{
		Pre:  c.inner,
		Post: &Parameter{loc.String()},
		Sep:  "::TIMESTAMP WITH TIME ZONE AT TIME ZONE ",
	}
	return c
}
Beispiel #2
0
func (u *User) SetLocation(loc *time.Location) error {
	if _, err := u.con.stmt[qSetLocation].Exec(loc.String(), uint64(u.id)); err != nil {
		return err
	}

	u.location = loc
	return nil
}
Beispiel #3
0
func NewDynamicTimeZone(location *time.Location) *TimeZone {
	t := new(TimeZone)
	t.Id = location.String()
	t.ExtLocationName = location.String()
	t.Url = values.NewUrl(url.URL{
		Scheme: "http",
		Host:   "tzurl.org",
		Path:   fmt.Sprintf("/zoneinfo/%s", t.Id),
	})
	return t
}
Beispiel #4
0
func (con *MySQLDBCon) AddUser(email string, pwhash []byte, location *time.Location, active bool, acCode string) (model.User, error) {
	now := time.Now()

	tx, err := con.con.Begin()
	if err != nil {
		return nil, err
	}

	insjob := tx.Stmt(con.stmt[qInsertUser])

	res, err := insjob.Exec(email, string(pwhash), location.String(), b2i(active), acCode, now.Unix())
	if err != nil {
		tx.Rollback()
		return nil, err
	}

	_id, err := res.LastInsertId()
	if err != nil {
		tx.Rollback()
		return nil, err
	}

	if err := tx.Commit(); err != nil {
		return nil, err
	}

	return &User{
		con:      con,
		id:       DBID(_id),
		email:    email,
		passwd:   string(pwhash),
		acCode:   acCode,
		location: location,
		added:    now,
		active:   active,
	}, nil
}
Beispiel #5
0
func (db *BotDB) SetTimeZone(user uint64, tz *time.Location) error {
	_, err := db.sql_SetTimeZone.Exec(tz.String(), user)
	db.log.LogError("SetTimeZone error: ", err)
	return err
}