use toml.DateTime; fix metadata.toml writing bug
This commit is contained in:
parent
dd54e8cc49
commit
a3b9ec2cb6
2 changed files with 10 additions and 15 deletions
|
|
@ -22,7 +22,7 @@ type (
|
|||
Metadata struct {
|
||||
Title string `toml:"title"`
|
||||
Part int `toml:"part"`
|
||||
Date string `toml:"date"`
|
||||
Date toml.LocalDate `toml:"date"`
|
||||
Tags []string `toml:"tags"`
|
||||
FootageDir string `toml:"footage_dir"`
|
||||
Uploaded bool `toml:"uploaded"`
|
||||
|
|
@ -107,20 +107,20 @@ func ReadMetadata(directory string) (*Metadata, error) {
|
|||
}
|
||||
|
||||
func WriteMetadata(directory string, metadata *Metadata) (error) {
|
||||
file, err := os.OpenFile(
|
||||
path.Join(directory, METADATA_FILENAME),
|
||||
os.O_CREATE | os.O_RDWR, 0644,
|
||||
)
|
||||
data, err := toml.Marshal(metadata)
|
||||
if err != nil { return err }
|
||||
|
||||
err = toml.NewEncoder(file).Encode(metadata)
|
||||
err = os.WriteFile(path.Join(directory, METADATA_FILENAME), data, 0644)
|
||||
return err
|
||||
}
|
||||
|
||||
func DefaultMetadata() *Metadata {
|
||||
return &Metadata{
|
||||
Title: "Untitled Stream",
|
||||
Date: time.Now().Format("2006-01-02"),
|
||||
Date: toml.LocalDate{
|
||||
Year: time.Now().Year(),
|
||||
Month: int(time.Now().Month()),
|
||||
Day: time.Now().Day(),
|
||||
},
|
||||
Part: 0,
|
||||
Category: &Category{
|
||||
Name: "Something",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue