summary refs log tree commit diff
path: root/Completion/Unix/Command/_date
blob: ff3bac398b0dbdc9c8cf2fe3dc97c56c0aaad5f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#compdef date gdate

local -a args alts

if _pick_variant gnu="Free Software Foundation" unix --version; then
  args=(
    '-d[output specified date]:time string'
    '-f[output dates specified in file]:file:_files'
    '-I-[iso-8601]:precision:(date hours minutes seconds)'
    '-r[reference]:file:_files'
    '-R[RFC2822 format]'
    '-s[set]:time string'
    '--rfc-3339=-[output date and time in RFC 3339 format]:output type:(date seconds ns)'
    --
    '*=FILE*:file:_files'
    '*=DATEFILE*:date file:_files'
  )
else
  case "$OSTYPE" in
    solaris*)
      args=( '-a:adjustment' )
    ;;
    darwin*|dragonfly*|netbsd*|openbsd*)
      args+=( '-r[specify reference time]:seconds since epoch' )
    ;|
    freebsd*|darwin*|dragonfly*|netbsd*|openbsd*)
      args=(
	'-n[only set time on current machine]'
	'-d:daylight saving time value'
	'-j[do not try to set date]'
	'-t:minutes west of GMT'
      )
    ;|
    freebsd*)
      alts=(
	'seconds:sec:_guard "(0x[0-9a-fA-F]#|[0-9]#)" "seconds since epoch"'
	'files:file:_files'
      )
      args+=(
	'-r[reference time: file modification or literal time]:reference: _alternative $alts'
	'-R[RFC2822 format]'
      )
    ;|
    freebsd*|dragonfly*|darwin*)
      args+=( '-f:parsing format' '-v:adjustment value' )
    ;;
    openbsd*)
      args+=( '-z[specify timezone for output]:time zone:_time_zone')
    ;|
    openbsd*|netbsd*) args=( '-a[gradually skew]' ) ;;
  esac
fi

_arguments \
  '-u[display or set time in UTC]' \
  ': :_guard "^--*" "format or date"' \
  "$args[@]"