mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
Add %s format specifier for strftime (#1335)
This commit is contained in:
parent
3baebea7a3
commit
b30aceae36
15 changed files with 23 additions and 15 deletions
|
|
@ -3434,5 +3434,5 @@ MILLER(1) MILLER(1)
|
|||
|
||||
|
||||
|
||||
2023-07-02 MILLER(1)
|
||||
2023-07-04 MILLER(1)
|
||||
</pre>
|
||||
|
|
|
|||
|
|
@ -3413,4 +3413,4 @@ MILLER(1) MILLER(1)
|
|||
|
||||
|
||||
|
||||
2023-07-02 MILLER(1)
|
||||
2023-07-04 MILLER(1)
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ Notes:
|
|||
* For `strftime`, this is thanks to [https://github.com/lestrrat-go/strftime](https://github.com/lestrrat-go/strftime), with a Miller-specific modification for fractional seconds.
|
||||
* For `strftime`, this is thanks to [https://github.com/pbnjay/strptime](https://github.com/pbnjay/strptime), with Miller-specific modifications.
|
||||
|
||||
Available format strings for `strftime`, taken directly from [https://github.com/lestrrat-go/strftime](https://github.com/lestrrat-go/strftime) except for `%1..%9`, `%N`, and `%O` which are Miller-specific additions:
|
||||
Available format strings for `strftime`, taken directly from [https://github.com/lestrrat-go/strftime](https://github.com/lestrrat-go/strftime) except for `%1..%9`, `%s`, `%N`, and `%O` which are Miller-specific additions:
|
||||
|
||||
| Pattern | Description |
|
||||
|---------|-------------|
|
||||
|
|
@ -274,6 +274,7 @@ Available format strings for `strftime`, taken directly from [https://github.com
|
|||
| `%p` | national representation of either "ante meridiem" (a.m.) or "post meridiem" (p.m.) as appropriate. |
|
||||
| `%R` | equivalent to `%H:%M` |
|
||||
| `%r` | equivalent to `%I:%M:%S %p` |
|
||||
| `%s` | integer seconds since the epoch |
|
||||
| `%S` | the second as a decimal number (00-60) |
|
||||
| `%1S`, ..., `%9S` | the second as a decimal number (00-60) with 1..9 decimal places, respectively |
|
||||
| `%T` | equivalent to `%H:%M:%S` |
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ Notes:
|
|||
* For `strftime`, this is thanks to [https://github.com/lestrrat-go/strftime](https://github.com/lestrrat-go/strftime), with a Miller-specific modification for fractional seconds.
|
||||
* For `strftime`, this is thanks to [https://github.com/pbnjay/strptime](https://github.com/pbnjay/strptime), with Miller-specific modifications.
|
||||
|
||||
Available format strings for `strftime`, taken directly from [https://github.com/lestrrat-go/strftime](https://github.com/lestrrat-go/strftime) except for `%1..%9`, `%N`, and `%O` which are Miller-specific additions:
|
||||
Available format strings for `strftime`, taken directly from [https://github.com/lestrrat-go/strftime](https://github.com/lestrrat-go/strftime) except for `%1..%9`, `%s`, `%N`, and `%O` which are Miller-specific additions:
|
||||
|
||||
| Pattern | Description |
|
||||
|---------|-------------|
|
||||
|
|
@ -206,6 +206,7 @@ Available format strings for `strftime`, taken directly from [https://github.com
|
|||
| `%p` | national representation of either "ante meridiem" (a.m.) or "post meridiem" (p.m.) as appropriate. |
|
||||
| `%R` | equivalent to `%H:%M` |
|
||||
| `%r` | equivalent to `%I:%M:%S %p` |
|
||||
| `%s` | integer seconds since the epoch |
|
||||
| `%S` | the second as a decimal number (00-60) |
|
||||
| `%1S`, ..., `%9S` | the second as a decimal number (00-60) with 1..9 decimal places, respectively |
|
||||
| `%T` | equivalent to `%H:%M:%S` |
|
||||
|
|
|
|||
|
|
@ -437,6 +437,11 @@ func init() {
|
|||
//return append(b, []byte(s))
|
||||
return append(b, s...)
|
||||
})
|
||||
appenderS := strftime.AppendFunc(func(b []byte, t time.Time) []byte {
|
||||
epochSeconds := t.Unix()
|
||||
s := fmt.Sprintf("%d", epochSeconds)
|
||||
return append(b, s...)
|
||||
})
|
||||
|
||||
ss := strftime.NewSpecificationSet()
|
||||
ss.Set('1', appender1)
|
||||
|
|
@ -450,6 +455,7 @@ func init() {
|
|||
ss.Set('9', appender9)
|
||||
ss.Set('N', appenderN)
|
||||
ss.Set('O', appenderO)
|
||||
ss.Set('s', appenderS)
|
||||
|
||||
strftimeExtensions = strftime.WithSpecificationSet(ss)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3413,4 +3413,4 @@ MILLER(1) MILLER(1)
|
|||
|
||||
|
||||
|
||||
2023-07-02 MILLER(1)
|
||||
2023-07-04 MILLER(1)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
.\" Title: mlr
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: ./mkman.rb
|
||||
.\" Date: 2023-07-02
|
||||
.\" Date: 2023-07-04
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "MILLER" "1" "2023-07-02" "\ \&" "\ \&"
|
||||
.TH "MILLER" "1" "2023-07-04" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Portability definitions
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ TZ is Asia/Istanbul
|
|||
1970-01-01 00:00:00 +0000
|
||||
1970-01-01 00:00:00 UTC
|
||||
1970-01-01 00:00:00 +0000
|
||||
00 000123456
|
||||
0 000123456
|
||||
00 123456
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ TZ is America/Sao_Paulo
|
|||
1970-01-01 00:00:00 +0000
|
||||
1970-01-01 00:00:00 UTC
|
||||
1970-01-01 00:00:00 +0000
|
||||
00 000123456
|
||||
0 000123456
|
||||
00 123456
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ TZ is UTC
|
|||
1970-01-01 00:00:00 +0000
|
||||
1970-01-01 00:00:00 UTC
|
||||
1970-01-01 00:00:00 +0000
|
||||
00 000123456
|
||||
0 000123456
|
||||
00 123456
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ TZ is Asia/Istanbul
|
|||
1970-01-01 00:00:00 +0000
|
||||
1970-01-01 00:00:00 UTC
|
||||
1970-01-01 00:00:00 +0000
|
||||
00 123456000
|
||||
0 123456000
|
||||
00 123456000
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ TZ is America/Sao_Paulo
|
|||
1970-01-01 00:00:00 +0000
|
||||
1970-01-01 00:00:00 UTC
|
||||
1970-01-01 00:00:00 +0000
|
||||
00 123456000
|
||||
0 123456000
|
||||
00 123456000
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ TZ is UTC
|
|||
1970-01-01 00:00:00 +0000
|
||||
1970-01-01 00:00:00 UTC
|
||||
1970-01-01 00:00:00 +0000
|
||||
00 123456000
|
||||
0 123456000
|
||||
00 123456000
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ end {
|
|||
print strfntime(123456, "%Y-%m-%d %H:%M:%S %z");
|
||||
print strfntime(0, "%Y-%m-%d %H:%M:%S %Z");
|
||||
print strfntime(0, "%Y-%m-%d %H:%M:%S %z");
|
||||
print strfntime(123456, "%S %N");
|
||||
print strfntime(123456, "%s %N");
|
||||
print strfntime(123456, "%S %O");
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ end {
|
|||
print strftime(0.123456, "%Y-%m-%d %H:%M:%S %z");
|
||||
print strftime(0.0, "%Y-%m-%d %H:%M:%S %Z");
|
||||
print strftime(0.0, "%Y-%m-%d %H:%M:%S %z");
|
||||
print strftime(0.123456, "%S %N");
|
||||
print strftime(0.123456, "%s %N");
|
||||
print strftime(0.123456, "%S %O");
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue