github.com/freetocompute/snapd@v0.0.0-20210618182524-2fb355d72fd9/osutil/settime_64bit.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  // +build !386
     4  // +build !arm
     5  // +build linux
     6  
     7  /*
     8   * Copyright (C) 2021 Canonical Ltd
     9   *
    10   * This program is free software: you can redistribute it and/or modify
    11   * it under the terms of the GNU General Public License version 3 as
    12   * published by the Free Software Foundation.
    13   *
    14   * This program is distributed in the hope that it will be useful,
    15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17   * GNU General Public License for more details.
    18   *
    19   * You should have received a copy of the GNU General Public License
    20   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    21   *
    22   */
    23  
    24  package osutil
    25  
    26  import (
    27  	"syscall"
    28  	"time"
    29  )
    30  
    31  func init() {
    32  	timeToTimeval = timeToTimeval64
    33  }
    34  
    35  func timeToTimeval64(t time.Time) *syscall.Timeval {
    36  	return &syscall.Timeval{
    37  		Sec:  int64(t.Unix()),
    38  		Usec: int64(t.Nanosecond() / 1000),
    39  	}
    40  }