summaryrefslogtreecommitdiff
path: root/lib/btrfs/btrfsprim/misc.go
blob: 43ba306a9b545e958005890305ca36ae6eda0466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (C) 2022-2023  Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later

// Package btrfsprim contains primitive btrfs datatypes, that all
// other btrfs sub-packages may make use of.
package btrfsprim

import (
	"time"

	"git.lukeshu.com/btrfs-progs-ng/lib/binstruct"
)

type Generation uint64

type Time struct {
	Sec           int64  `bin:"off=0x0, siz=0x8"` // Number of seconds since 1970-01-01T00:00:00Z.
	NSec          uint32 `bin:"off=0x8, siz=0x4"` // Number of nanoseconds since the beginning of the second.
	binstruct.End `bin:"off=0xc"`
}

func (t Time) ToStd() time.Time {
	return time.Unix(t.Sec, int64(t.NSec))
}