aboutsummaryrefslogtreecommitdiff
path: root/tests/builtin/date.testscript
blob: 0b466c3aa8e6d6b573621590ef6821edd10aec05 (plain)
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
# file      : tests/builtin/date.testscript
# license   : MIT; see accompanying LICENSE file

test.arguments = "date"

: timezone
:
: Here we also make sure that the dates are not only verified but can also be
: seen if running with the verbosity level 2 and up, which helps with
: troubleshooting.
:
{
  $* | set local;
  $* --utc | set utc;

  echo "local: $local"  >~'%local: \S+ \S+ .+ \d{2}:\d{2}:\d{2} .+ \d+%';
  echo "utc: $utc" >~'%utc: \S+ \S+ .+ \d{2}:\d{2}:\d{2} .+ \d+%'
}

: format
:
{
  : non-empty
  :
  $* '+%Y-%m-%d %H:%M:%S%[.N]' >~'%\d+-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{9}%'

  : empty
  :
  $* '+' >''

  : no-leading-plus
  :
  $* '%Y-%m-%d %H:%M:%S' 2>>EOE!= 0
    date: date format argument must start with '+'
    EOE
}

: unknown-option
:
$* -d '+%Y-%m-%d %H:%M:%S' 2>>EOE!= 0
  date: unknown option '-d'
  EOE

: unexpected-arg
:
$* '+%Y-%m-%d %H:%M:%S' '%Y' 2>>EOE!= 0
  date: unexpected argument '%Y'
  EOE