Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. this is a post abou mu ;ofe
  2.  
  3.  
  4.  
  5. // Timestamp represents a BSON timestamp value.
  6. type Timestamp struct {
  7. T uint32
  8. I uint32
  9. }
  10.  
  11. // Equal compares tp to tp2 and returns true is the are equal.
  12. func (tp Timestamp) Equal(tp2 Timestamp) bool {
  13. return tp.T == tp2.T && tp.I == tp2.I
  14. }
  15.  
  16. // IsZero returns if tp is the zero Timestamp
  17. func (tp Timestamp) IsZero() bool {
  18. return tp.T == 0 && tp.I == 0
  19. }
  20.  
  21. // CompareTimestamp returns an integer comparing two Timestamps, where T is compared first, followed by I.
  22. // Returns 0 if tp = tp2, 1 if tp > tp2, -1 if tp < tp2.
  23. func CompareTimestamp(tp, tp2 Timestamp) int {
  24. if tp.Equal(tp2) {
  25. return 0
  26. }
  27.  
  28. if tp.T > tp2.T {
  29. return 1
  30. }
  31.  
  32.  
  33.  
  34. https://pastebin.com/1NKjGaP3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement