mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-07-30 13:47:46 +00:00
rename date format
to format date
(#571)
This commit is contained in:
parent
1d8457fa9d
commit
be47e43db6
17 changed files with 37 additions and 37 deletions
|
@ -7,7 +7,7 @@ def iter_inc [incr mult iter] {
|
|||
let is_release = (input "Did you compile in a release mode? y/n ")
|
||||
|
||||
if ($is_release | str downcase | str trim) == "y" {
|
||||
print $"running test 0 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 0 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 0. this has wrong output
|
||||
let 0 = (seq 1 10 | each { timeit {
|
||||
let height = 40
|
||||
|
@ -27,7 +27,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
}} | math avg)
|
||||
|
||||
|
||||
print $"running test 1 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 1 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 1. Fixed newline to fix the output (char cr)
|
||||
let 1 = (seq 1 10 | each { timeit {
|
||||
let height = 40
|
||||
|
@ -46,7 +46,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
} | str join
|
||||
}} | math avg)
|
||||
|
||||
print $"running test 2 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 2 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 2. Replace (char sp) with just space
|
||||
let 2 = (seq 1 10 | each { timeit {
|
||||
let height = 40
|
||||
|
@ -65,7 +65,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
} | str join
|
||||
}} | math avg)
|
||||
|
||||
print $"running test 3 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 3 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 3. Precompute (ansi -e '48;2;0;0;') and (ansi -e '0m') -- seems to be slower
|
||||
let 3 = (seq 1 10 | each { timeit {
|
||||
let height = 40
|
||||
|
@ -86,7 +86,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
} | str join
|
||||
}} | math avg)
|
||||
|
||||
print $"running test 4 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 4 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 4. Inline iter_inc call
|
||||
let 4 = (seq 1 10 | each { timeit {
|
||||
let height = 40
|
||||
|
@ -105,7 +105,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
} | str join
|
||||
}} | math avg)
|
||||
|
||||
print $"running test 5 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 5 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 5. Combine (char sp) substitution and iter_inc inlining
|
||||
let 5 = (seq 1 10 | each { timeit {
|
||||
let height = 40
|
||||
|
@ -124,7 +124,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
} | str join
|
||||
}} | math avg)
|
||||
|
||||
print $"running test 6 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 6 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 6. The above with par-each outer loop (using par-each anywhere else breaks the output)
|
||||
let 6 = (seq 1 10 | each { timeit {
|
||||
let height = 40
|
||||
|
|
|
@ -9,7 +9,7 @@ let is_release = "y"
|
|||
|
||||
if ($is_release | str downcase | str trim) == "y" {
|
||||
|
||||
print $"running test 0 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 0 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 0. this has wrong output
|
||||
let 0 = (seq 10 | timeit {
|
||||
let height = 40
|
||||
|
@ -29,7 +29,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
} | math avg)
|
||||
|
||||
|
||||
print $"running test 1 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 1 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 1. Fixed newline to fix the output (char cr)
|
||||
let 1 = (seq 10 | timeit {
|
||||
let height = 40
|
||||
|
@ -48,7 +48,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
} | str join
|
||||
} | math avg)
|
||||
|
||||
print $"running test 2 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 2 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 2. Replace (char sp) with just space
|
||||
let 2 = (seq 10 | timeit {
|
||||
let height = 40
|
||||
|
@ -67,7 +67,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
} | str join
|
||||
} | math avg)
|
||||
|
||||
print $"running test 3 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 3 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 3. Precompute (ansi -e '48;2;0;0;') and (ansi -e '0m') -- seems to be slower
|
||||
let 3 = (seq 10 | timeit {
|
||||
let height = 40
|
||||
|
@ -88,7 +88,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
} | str join
|
||||
} | math avg)
|
||||
|
||||
print $"running test 4 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 4 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 4. Inline iter_inc call
|
||||
let 4 = (seq 10 | timeit {
|
||||
let height = 40
|
||||
|
@ -107,7 +107,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
} | str join
|
||||
} | math avg)
|
||||
|
||||
print $"running test 5 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 5 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 5. Combine (char sp) substitution and iter_inc inlining
|
||||
let 5 = (seq 10 | timeit {
|
||||
let height = 40
|
||||
|
@ -126,7 +126,7 @@ if ($is_release | str downcase | str trim) == "y" {
|
|||
} | str join
|
||||
} | math avg)
|
||||
|
||||
print $"running test 6 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
print $"running test 6 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
|
||||
# 6. The above with par-each outer loop (using par-each anywhere else breaks the output)
|
||||
let 6 = (seq 10 | timeit {
|
||||
let height = 40
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
- [ ] tweet about the new release
|
||||
|
||||
## 7. Create the next release note PR on the website
|
||||
- [ ] run `./make_release/release-note/create-pr 0.xx.0 ((date now) + 4wk | date format "%Y-%m-%d" | into datetime)`
|
||||
- [ ] run `./make_release/release-note/create-pr 0.xx.0 ((date now) + 4wk | format date "%Y-%m-%d" | into datetime)`
|
||||
|
||||
## 8. Bump the version as development
|
||||
- [ ] bump the patch version on [`nushell`] ([example][nushell dev example]) by running
|
||||
|
|
|
@ -43,7 +43,7 @@ def main [
|
|||
let branch = $"release-notes-($version)"
|
||||
|
||||
let blog_path = (
|
||||
$repo | path join "blog" $"($date | date format "%Y-%m-%d")-nushell_($version | str replace --all --string '.' '_').md"
|
||||
$repo | path join "blog" $"($date | format date "%Y-%m-%d")-nushell_($version | str replace --all --string '.' '_').md"
|
||||
)
|
||||
|
||||
let title = $"Release notes for `($version)`"
|
||||
|
|
|
@ -15,9 +15,9 @@ def main [
|
|||
--pretty: bool # pretty-print for the MarkDown release not
|
||||
--no-author: bool # do not group the contributions by author
|
||||
] {
|
||||
let date = $date | default ((date now) - 4wk) | date format "%Y-%m-%d"
|
||||
let date = $date | default ((date now) - 4wk) | format date "%Y-%m-%d"
|
||||
|
||||
let since = (date now | date format %F | into datetime) - ($date | into datetime)
|
||||
let since = (date now | format date %F | into datetime) - ($date | into datetime)
|
||||
log info $"listing PRs in ($repo) since ($date) \(($since) ago\)"
|
||||
|
||||
let query = if $label == null {
|
||||
|
|
|
@ -334,7 +334,7 @@ export def container-create [
|
|||
$debug $appimage $netadmin $clip
|
||||
$mnt $vols $workdir $cache
|
||||
] | flatten)
|
||||
let name = $"($img | split row '/' | last | str replace ':' '-')_(date now | date format %m%d%H%M)"
|
||||
let name = $"($img | split row '/' | last | str replace ':' '-')_(date now | format date %m%d%H%M)"
|
||||
if $dry_run {
|
||||
echo $"docker ($ns | str join ' ') run --name ($name) ($args|str join ' ') ($img) ($cmd | flatten)"
|
||||
} else {
|
||||
|
|
|
@ -6,7 +6,7 @@ def logtime [msg act] {
|
|||
| into string
|
||||
| str replace ' ' '')
|
||||
|
||||
echo $'($start | date format '%Y-%m-%d_%H:%M:%S%z')(char tab)($period)(char tab)($msg)(char newline)'
|
||||
echo $'($start | format date '%Y-%m-%d_%H:%M:%S%z')(char tab)($period)(char tab)($msg)(char newline)'
|
||||
| save -a ~/.cache/nushell/time.log
|
||||
|
||||
return $result
|
||||
|
|
|
@ -217,7 +217,7 @@ export def get_right_prompt [os use_nerd_fonts] {
|
|||
})
|
||||
(ansi { fg: $TERM_FG bg: $TIME_BG})
|
||||
(char space)
|
||||
(date now | date format '%m/%d/%Y %I:%M:%S%.3f')
|
||||
(date now | format date '%m/%d/%Y %I:%M:%S%.3f')
|
||||
(char space)
|
||||
($R)
|
||||
] | str join)
|
||||
|
@ -231,7 +231,7 @@ export def get_right_prompt [os use_nerd_fonts] {
|
|||
})
|
||||
(ansi { fg: $TERM_FG bg: $TIME_BG})
|
||||
(char space)
|
||||
(date now | date format '%I:%M:%S %p')
|
||||
(date now | format date '%I:%M:%S %p')
|
||||
(char space)
|
||||
($R)
|
||||
] | str join)
|
||||
|
|
|
@ -351,7 +351,7 @@ def get_time_segment [os color_mode] {
|
|||
($time_color)
|
||||
($time_bg_color)
|
||||
(char space)
|
||||
(date now | date format '%I:%M:%S %p')
|
||||
(date now | format date '%I:%M:%S %p')
|
||||
(char space)
|
||||
($R)
|
||||
] | str join)
|
||||
|
|
|
@ -84,7 +84,7 @@ def time_segment [] {
|
|||
} else {
|
||||
$'($theme.fst)%y-%m-%d[%w]%H:%M:%S'
|
||||
}
|
||||
[$bg $"(date now | date format $format)"]
|
||||
[$bg $"(date now | format date $format)"]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ def logtime [msg act] {
|
|||
let result = (do $act)
|
||||
let period = ($"((date now) - $start | into duration -c ns)" | str replace ' ' '')
|
||||
|
||||
echo $'($start | date format '%Y-%m-%d_%H:%M:%S%z')(char tab)($period)(char tab)($msg)(char newline)'
|
||||
echo $'($start | format date '%Y-%m-%d_%H:%M:%S%z')(char tab)($period)(char tab)($msg)(char newline)'
|
||||
| save -a ~/.cache/nushell/power_time.log
|
||||
|
||||
$result
|
||||
|
|
|
@ -11,7 +11,7 @@ def workspaces [] {
|
|||
|
||||
def create_right_prompt [] {
|
||||
let time_segment = ([
|
||||
(date now | date format '%r'),
|
||||
(date now | format date '%r'),
|
||||
" ",
|
||||
(workspaces)
|
||||
] | str join)
|
||||
|
|
|
@ -73,7 +73,7 @@ def get_weather_by_ip [locIdx: int, units: string, token: string] {
|
|||
let forecast = ($forecast_data.list | each {|day|
|
||||
{
|
||||
id: ($day.weather.0.id)
|
||||
dt: ($day.dt | into string | into datetime -z local | date format '%a, %b %e') #'%Y-%m-%d')
|
||||
dt: ($day.dt | into string | into datetime -z local | format date '%a, %b %e') #'%Y-%m-%d')
|
||||
high: ($day.temp.max)
|
||||
low: ($day.temp.min)
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ def get_weather_by_ip [locIdx: int, units: string, token: string] {
|
|||
let forecast = ($forecast_data.list | each {|day|
|
||||
{
|
||||
id: ($day.weather.0.id)
|
||||
dt: ($day.dt | into string | into datetime -z local | date format '%a, %b %e') #'%Y-%m-%d')
|
||||
dt: ($day.dt | into string | into datetime -z local | format date '%a, %b %e') #'%Y-%m-%d')
|
||||
high: ($day.temp.max)
|
||||
low: ($day.temp.min)
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ def timed_weather_run [
|
|||
Source: "expired-cache"
|
||||
Emoji: ($emoji)
|
||||
}
|
||||
$weather_table | upsert last_run_time {(date now | date format '%Y-%m-%d %H:%M:%S %z')} | save $weather_runtime_file
|
||||
$weather_table | upsert last_run_time {(date now | format date '%Y-%m-%d %H:%M:%S %z')} | save $weather_runtime_file
|
||||
}
|
||||
} else {
|
||||
# $"Unable to find [($weather_runtime_file)], creating it(char nl)"
|
||||
|
@ -67,7 +67,7 @@ def timed_weather_run [
|
|||
Source: "initial"
|
||||
Emoji: ($emoji)
|
||||
}
|
||||
$weather_table | upsert last_run_time {(date now | date format '%Y-%m-%d %H:%M:%S %z')} | save $weather_runtime_file
|
||||
$weather_table | upsert last_run_time {(date now | format date '%Y-%m-%d %H:%M:%S %z')} | save $weather_runtime_file
|
||||
}
|
||||
} else {
|
||||
echo "Your command did not run because you are not on Windows..."
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use get-weather.nu get_weather
|
||||
|
||||
# Create a mutable weather table to hold the weather data
|
||||
$env.WEATHER = (get_weather | upsert last_run_time { (date now | date format '%Y-%m-%d %H:%M:%S %z')})
|
||||
$env.WEATHER = (get_weather | upsert last_run_time { (date now | format date '%Y-%m-%d %H:%M:%S %z')})
|
||||
|
||||
#command to run at interval
|
||||
def-env timed_weather_run [
|
||||
|
@ -30,7 +30,7 @@ def-env timed_weather_run [
|
|||
} else {
|
||||
# $"interval met, running command: [($command)](char nl)"
|
||||
|
||||
$env.WEATHER = (get_weather | upsert last_run_time { (date now | date format '%Y-%m-%d %H:%M:%S %z')})
|
||||
$env.WEATHER = (get_weather | upsert last_run_time { (date now | format date '%Y-%m-%d %H:%M:%S %z')})
|
||||
let temp = ($env.WEATHER.Temperature)
|
||||
let emoji = ($env.WEATHER.Emoji)
|
||||
{
|
||||
|
|
|
@ -132,7 +132,7 @@ export def-env get_weather_by_interval [INTERVAL_WEATHER] {
|
|||
|
||||
if ($LAST_WEATHER_TIME | into datetime) + $INTERVAL_WEATHER < (date now) {
|
||||
let WEATHER = (get_weather_for_prompt (get_location 0))
|
||||
let NEW_WEATHER_TIME = (date now | date format '%Y-%m-%d %H:%M:%S %z')
|
||||
let NEW_WEATHER_TIME = (date now | format date '%Y-%m-%d %H:%M:%S %z')
|
||||
|
||||
$last_runtime_data | upsert weather $WEATHER | upsert last_weather_time $NEW_WEATHER_TIME | save $weather_runtime_file
|
||||
|
||||
|
@ -142,7 +142,7 @@ export def-env get_weather_by_interval [INTERVAL_WEATHER] {
|
|||
}
|
||||
} else {
|
||||
let WEATHER = (get_weather_for_prompt (get_location 0))
|
||||
let LAST_WEATHER_TIME = (date now | date format '%Y-%m-%d %H:%M:%S %z')
|
||||
let LAST_WEATHER_TIME = (date now | format date '%Y-%m-%d %H:%M:%S %z')
|
||||
|
||||
let WEATHER_DATA = {
|
||||
"weather": ($WEATHER)
|
||||
|
|
|
@ -406,12 +406,12 @@ def gnu-plot [
|
|||
|
||||
# date string YYYY-MM-DD
|
||||
def ymd [] {
|
||||
(date now | date format %Y-%m-%d)
|
||||
(date now | format date %Y-%m-%d)
|
||||
}
|
||||
|
||||
# date string DD-MM-YYYY
|
||||
def dmy [] {
|
||||
(date now | date format %d-%m-%Y)
|
||||
(date now | format date %d-%m-%Y)
|
||||
}
|
||||
|
||||
# create directory and cd into it.
|
||||
|
|
|
@ -46,7 +46,7 @@ print ($table | group-by user_login | transpose user prs | each { |row|
|
|||
# ╰───┴──────────────────────────────────────────────────────────┴─────────────────┴───────────────────────────────────────────────────────╯
|
||||
|
||||
def log [message:any] {
|
||||
let now = (date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
let now = (date now | format date '%Y%m%d_%H%M%S.%f')
|
||||
let mess = ([$now '|DBG|' $message (char newline)] | str join)
|
||||
echo $mess
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue