Repository: rclone/rclone
File: backend/local/metadata.go (Go)

Code before:
		Help:    "Time of file birth (creation)",
		Type:    "RFC 3339",
		Example: "2006-01-02T15:04:05.999999999Z07:00",
	},
}

// parse a time string from metadata with key
func (o *Object) parseMetadataTime(m fs.Metadata, key string) (t time.Time, ok bool) {
	value, ok := m[key]
	if ok {
		var err error
		t, err = time.Parse(metadataTimeFormat, value)
		if err != nil {
			fs.Debugf(o, "failed to parse metadata %s: %q: %v", key, value, err)
			ok = false
		}
	}
	return t, ok
}

// parse am int from metadata with key and base
func (o *Object) parseMetadataInt(m fs.Metadata, key string, base int) (result int, ok bool) {
	value, ok := m[key]
	if ok {
		var err error
		parsed, err := strconv.ParseInt(value, base, 32)
		if err != nil {
			fs.Debugf(o, "failed to parse metadata %s: %q: %v", key, value, err)
			ok = false
		}
		result = int(parsed)
	}
	return result, ok
}

// Write the metadata into the file
//
// It isn't possible to set the ctime and btime under Unix
func (o *Object) writeMetadataToFile(m fs.Metadata) (outErr error) {
	var err error
	atime, atimeOK := o.parseMetadataTime(m, "atime")
	mtime, mtimeOK := o.parseMetadataTime(m, "mtime")
	btime, btimeOK := o.parseMetadataTime(m, "btime")
	if atimeOK || mtimeOK {
		if atimeOK && !mtimeOK {
			mtime = atime
		}
		if !atimeOK && mtimeOK {
			atime = mtime
		}
		err = o.setTimes(atime, mtime)

Review comment (suggestion):
I don't think this is the right fix as `int` is 64 bit on most platforms but 32 on some.

I think the right fix is probably using `strconv.Atoi` which hopefully deals with the sizes of integers properly. Looking at [the source of Atoi](https://cs.opensource.google/go/go/+/refs/tags/go1.23.0:src/strconv/atoi.go;l=242) I think it does the right thing.

Code after:
		Help:    "Time of file birth (creation)",
		Type:    "RFC 3339",
		Example: "2006-01-02T15:04:05.999999999Z07:00",
	},
}

// parse a time string from metadata with key
func (o *Object) parseMetadataTime(m fs.Metadata, key string) (t time.Time, ok bool) {
	value, ok := m[key]
	if ok {
		var err error
		t, err = time.Parse(metadataTimeFormat, value)
		if err != nil {
			fs.Debugf(o, "failed to parse metadata %s: %q: %v", key, value, err)
			ok = false
		}
	}
	return t, ok
}

// parse am int from metadata with key and base
func (o *Object) parseMetadataInt(m fs.Metadata, key string, base int) (result int, ok bool) {
	value, ok := m[key]
	if ok {
		var err error
		parsed, err := strconv.ParseInt(value, base, 0)
		if err != nil {
			fs.Debugf(o, "failed to parse metadata %s: %q: %v", key, value, err)
			ok = false
		}
		result = int(parsed)
	}
	return result, ok
}

// Write the metadata into the file
//
// It isn't possible to set the ctime and btime under Unix
func (o *Object) writeMetadataToFile(m fs.Metadata) (outErr error) {
	var err error
	atime, atimeOK := o.parseMetadataTime(m, "atime")
	mtime, mtimeOK := o.parseMetadataTime(m, "mtime")
	btime, btimeOK := o.parseMetadataTime(m, "btime")
	if atimeOK || mtimeOK {
		if atimeOK && !mtimeOK {
			mtime = atime
		}
		if !atimeOK && mtimeOK {
			atime = mtime
		}
		err = o.setTimes(atime, mtime)