Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added flags to hide time or date #92

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/datetime-widget.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,35 @@ time_string=""

if [[ $date_format == "YMD" ]]; then
# Year Month Day date format
date_string="%Y-%m-%d"
date_string=" %Y-%m-%d"
elif [[ $date_format == "MDY" ]]; then
# Month Day Year date format
date_string="%m-%d-%Y"
date_string=" %m-%d-%Y"
elif [[ $date_format == "DMY" ]]; then
# Day Month Year date format
date_string="%d-%m-%Y"
date_string=" %d-%m-%Y"
elif [[ $date_format == "hide" ]]; then
# Day Month Year date format
date_string=""
else
# Default to YMD date format if not specified
date_string="%Y-%m-%d"
date_string=" %Y-%m-%d"
fi

if [[ $time_format == "12H" ]]; then
# 12-hour format with AM/PM
time_string="%I:%M %p"
time_string="%I:%M %p "
elif [[ $time_format == "hide" ]]; then
# 24-hour format
time_string=""
else
# Default to 24-hour format if not specified
time_string="%H:%M"
time_string="%H:%M "
fi

separator=""
if [[ $date_string && $time_string ]]; then
separator="❬ "
fi

echo "$RESET#[fg=${THEME[foreground]},bg=${THEME[bblack]}] $date_string #[]❬ $time_string "
echo "$RESET#[fg=${THEME[foreground]},bg=${THEME[bblack]}]$date_string $separator$time_string"
Loading