types.go 704 B

1234567891011121314151617181920212223
  1. // Discordgo - Discord bindings for Go
  2. // Available at https://github.com/bwmarrin/discordgo
  3. // Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
  4. // Use of this source code is governed by a BSD-style
  5. // license that can be found in the LICENSE file.
  6. // This file contains custom types, currently only a timestamp wrapper.
  7. package discordgo
  8. import (
  9. "time"
  10. )
  11. // Timestamp stores a timestamp, as sent by the Discord API.
  12. type Timestamp string
  13. // Parse parses a timestamp string into a time.Time object.
  14. // The only time this can fail is if Discord changes their timestamp format.
  15. func (t Timestamp) Parse() (time.Time, error) {
  16. return time.Parse(time.RFC3339, string(t))
  17. }