github.com/mailgun/holster/v4@v4.20.0/clock/go19.go (about)

     1  //go:build go1.9
     2  // +build go1.9
     3  
     4  // This file introduces aliases to allow using of the clock package as a
     5  // drop-in replacement of the standard time package.
     6  
     7  package clock
     8  
     9  import "time"
    10  
    11  type (
    12  	Time     = time.Time
    13  	Duration = time.Duration
    14  	Location = time.Location
    15  
    16  	Weekday = time.Weekday
    17  	Month   = time.Month
    18  
    19  	ParseError = time.ParseError
    20  )
    21  
    22  const (
    23  	Nanosecond  = time.Nanosecond
    24  	Microsecond = time.Microsecond
    25  	Millisecond = time.Millisecond
    26  	Second      = time.Second
    27  	Minute      = time.Minute
    28  	Hour        = time.Hour
    29  
    30  	Sunday    = time.Sunday
    31  	Monday    = time.Monday
    32  	Tuesday   = time.Tuesday
    33  	Wednesday = time.Wednesday
    34  	Thursday  = time.Thursday
    35  	Friday    = time.Friday
    36  	Saturday  = time.Saturday
    37  
    38  	January   = time.January
    39  	February  = time.February
    40  	March     = time.March
    41  	April     = time.April
    42  	May       = time.May
    43  	June      = time.June
    44  	July      = time.July
    45  	August    = time.August
    46  	September = time.September
    47  	October   = time.October
    48  	November  = time.November
    49  	December  = time.December
    50  
    51  	ANSIC       = time.ANSIC
    52  	UnixDate    = time.UnixDate
    53  	RubyDate    = time.RubyDate
    54  	RFC822      = time.RFC822
    55  	RFC822Z     = time.RFC822Z
    56  	RFC850      = time.RFC850
    57  	RFC1123     = time.RFC1123
    58  	RFC1123Z    = time.RFC1123Z
    59  	RFC3339     = time.RFC3339
    60  	RFC3339Nano = time.RFC3339Nano
    61  	Kitchen     = time.Kitchen
    62  	Stamp       = time.Stamp
    63  	StampMilli  = time.StampMilli
    64  	StampMicro  = time.StampMicro
    65  	StampNano   = time.StampNano
    66  )
    67  
    68  var (
    69  	UTC   = time.UTC
    70  	Local = time.Local
    71  )
    72  
    73  func Date(year int, month Month, day, hour, min, sec, nsec int, loc *Location) Time {
    74  	return time.Date(year, month, day, hour, min, sec, nsec, loc)
    75  }
    76  
    77  func FixedZone(name string, offset int) *Location {
    78  	return time.FixedZone(name, offset)
    79  }
    80  
    81  func LoadLocation(name string) (*Location, error) {
    82  	return time.LoadLocation(name)
    83  }
    84  
    85  func Parse(layout, value string) (Time, error) {
    86  	return time.Parse(layout, value)
    87  }
    88  
    89  func ParseDuration(s string) (Duration, error) {
    90  	return time.ParseDuration(s)
    91  }
    92  
    93  func ParseInLocation(layout, value string, loc *Location) (Time, error) {
    94  	return time.ParseInLocation(layout, value, loc)
    95  }
    96  
    97  func Unix(sec, nsec int64) Time {
    98  	return time.Unix(sec, nsec)
    99  }
   100  
   101  func Since(t Time) Duration {
   102  	return getProvider().Now().Sub(t)
   103  }
   104  
   105  func Until(t Time) Duration {
   106  	return t.Sub(getProvider().Now())
   107  }