Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this is a post abou mu ;ofe
- // Timestamp represents a BSON timestamp value.
- type Timestamp struct {
- T uint32
- I uint32
- }
- // Equal compares tp to tp2 and returns true is the are equal.
- func (tp Timestamp) Equal(tp2 Timestamp) bool {
- return tp.T == tp2.T && tp.I == tp2.I
- }
- // IsZero returns if tp is the zero Timestamp
- func (tp Timestamp) IsZero() bool {
- return tp.T == 0 && tp.I == 0
- }
- // CompareTimestamp returns an integer comparing two Timestamps, where T is compared first, followed by I.
- // Returns 0 if tp = tp2, 1 if tp > tp2, -1 if tp < tp2.
- func CompareTimestamp(tp, tp2 Timestamp) int {
- if tp.Equal(tp2) {
- return 0
- }
- if tp.T > tp2.T {
- return 1
- }
- https://pastebin.com/1NKjGaP3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement