mirror of
https://github.com/d0zingcat/dotfiles.git
synced 2026-05-13 23:16:44 +00:00
update racast/wezterm
This commit is contained in:
31
raycast/epoch-to-human-date.sh
Executable file
31
raycast/epoch-to-human-date.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Required parameters:
|
||||
# @raycast.schemaVersion 1
|
||||
# @raycast.title Convert Epoch to Human-Readable Date
|
||||
# @raycast.mode silent
|
||||
# @raycast.packageName Conversions
|
||||
#
|
||||
# Optional parameters:
|
||||
# @raycast.icon ⏱
|
||||
# @raycast.needsConfirmation false
|
||||
# @raycast.argument1 {"type": "text", "placeholder": "Timestamp Epoch"}
|
||||
#
|
||||
# Documentation:
|
||||
# @raycast.description Convert epoch to human-readable date.
|
||||
# @raycast.author Siyuan Zhang | d0zingcat
|
||||
# @raycast.authorURL https://github.com/kastnerorz | https://d0zingcat.dev
|
||||
|
||||
epoch=${1}
|
||||
size=${#epoch}
|
||||
if [[ $size == "10" ]]; then
|
||||
human=$(echo $(date -r $epoch "+%F %T"))
|
||||
echo -n "$human" | pbcopy
|
||||
elif [[ $size == "13" ]]; then
|
||||
human=$(echo $(date -r $(($epoch / 1000)) "+%F %T"))
|
||||
echo -n "$human" | pbcopy
|
||||
else
|
||||
echo 'invalid data(valid length: 10 or 13)'
|
||||
exit 1
|
||||
fi
|
||||
echo "Converted $epoch to $human"
|
||||
38
raycast/human-date-to-epoch.sh
Executable file
38
raycast/human-date-to-epoch.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Required parameters:
|
||||
# @raycast.schemaVersion 1
|
||||
# @raycast.title Convert Human-Readable Date To Epoch
|
||||
# @raycast.mode silent
|
||||
# @raycast.packageName Conversions
|
||||
#
|
||||
# Optional parameters:
|
||||
# @raycast.icon ⏱
|
||||
# @raycast.needsConfirmation false
|
||||
# @raycast.argument1 {"type": "text", "placeholder": "Date"}
|
||||
#
|
||||
# Documentation:
|
||||
# @raycast.description Convert human-readable date to timestamp epoch.
|
||||
# @raycast.author Siyuan Zhang | d0zingcat
|
||||
# @raycast.authorURL https://github.com/kastnerorz | https://d0zingcat.dev
|
||||
|
||||
date=${1}
|
||||
length=${#date}
|
||||
if [[ $length -eq 19 ]]; then
|
||||
epoch=$(echo $(date -jRuf "%F %T" "$date" "+%s"))
|
||||
echo -n "$epoch" | pbcopy
|
||||
elif [[ $length -eq 10 ]]; then
|
||||
epoch=$(echo $(date -jRuf "%F %T" "$date 00:00:00" "+%s"))
|
||||
echo -n "$epoch" | pbcopy
|
||||
elif [[ $length -eq 8 ]]; then
|
||||
yyyy=$(echo $date | cut -c1-4)
|
||||
mm=$(echo $date | cut -c5-6)
|
||||
dd=$(echo $date | cut -c7-8)
|
||||
epoch=$(echo $(date -jRuf "%F %T" "$yyyy-$mm-$dd 00:00:00" "+%s"))
|
||||
echo -n "$epoch" | pbcopy
|
||||
else
|
||||
echo "Invalid date format."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Converted $date to $epoch"
|
||||
Reference in New Issue
Block a user