github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/cmds/core/date/date_unix.go (about)

     1  // Copyright 2015-2017 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !plan9
     6  // +build !plan9
     7  
     8  package main
     9  
    10  import (
    11  	"log"
    12  	"syscall"
    13  	"time"
    14  )
    15  
    16  func setDate(d string, z *time.Location, clocksource Clock) error {
    17  	t, err := getTime(z, d, clocksource)
    18  	if err != nil {
    19  		log.Fatalf("%v: %v", d, err)
    20  	}
    21  	tv := syscall.NsecToTimeval(t.UnixNano())
    22  	return syscall.Settimeofday(&tv)
    23  }