sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
| 1 | # 2023-08-29 |
| 2 | # |
| 3 | # The author disclaims copyright to this source code. In place of |
| 4 | # a legal notice, here is a blessing: |
| 5 | # |
| 6 | # May you do good and not evil. |
| 7 | # May you find forgiveness for yourself and forgive others. |
| 8 | # May you share freely, never taking more than you give. |
| 9 | # |
| 10 | #*********************************************************************** |
| 11 | # |
| 12 | # Test cases for the strftime() SQL function. Comparisons against the |
| 13 | # C-library strftime() function. |
| 14 | |
| 15 | set testdir [file dirname $argv0] |
| 16 | source $testdir/tester.tcl |
| 17 | |
| 18 | # Skip this whole file if date and time functions are omitted |
| 19 | # at compile-time |
| 20 | # |
| 21 | ifcapable {!datetime} { |
| 22 | finish_test |
| 23 | return |
| 24 | } |
| 25 | |
| 26 | if {$tcl_platform(os)=="Linux"} { |
| 27 | if {"" eq [strftime {%P} 1]} { |
| 28 | # This is probably musl libc, which does not support |
| 29 | # %k, %l, %P |
| 30 | set FMT {%d,%e,%F,%H,%I,%j,%m,%M,%u,%w,%W,%Y,%%,%p,%U,%V,%G,%g} |
| 31 | } else { |
| 32 | set FMT {%d,%e,%F,%H,%k,%I,%l,%j,%m,%M,%u,%w,%W,%Y,%%,%P,%p,%U,%V,%G,%g} |
| 33 | } |
| 34 | } else { |
| 35 | set FMT {%d,%e,%F,%H,%I,%j,%p,%R,%u,%w,%W,%%} |
| 36 | } |
| 37 | for {set i 0} {$i<=24858} {incr i} { |
| 38 | set TS [expr {$i*86390}] |
| 39 | do_execsql_test date4-$i { |
| 40 | SELECT strftime($::FMT,$::TS,'unixepoch'); |
| 41 | } [list [strftime $FMT $TS]] |
| 42 | } |
| 43 | |
| 44 | finish_test |