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

Added ordinals support for time block #1824

Closed
wants to merge 8 commits into from
Closed

Added ordinals support for time block #1824

wants to merge 8 commits into from

Conversation

virajbhartiya
Copy link

Fixed #1323

I've added Ordinal support for time using chrono

@MaxVerevkin
Copy link
Collaborator

FYI, pre-commit can be run locally (pre-commit install)

@virajbhartiya
Copy link
Author

Thanks @MaxVerevkin, I test pre-commit locally then commit

@MaxVerevkin
Copy link
Collaborator

@virajbhartiya I believe you pushed to the wrong branch.

@virajbhartiya
Copy link
Author

virajbhartiya commented Mar 10, 2023

Yes, I was actually working on the padding issue but forgot the switch branches.
I'll fix it

@virajbhartiya
Copy link
Author

Hey @MaxVerevkin, can you help me understand why the checks are failing, I haven't made any changes in the cargo.toml file but still it's showing errors in it

Cargo.toml Outdated Show resolved Hide resolved
@@ -43,6 +43,7 @@ smart-default = "0.6"
swayipc-async = "2.0"
tokio-stream = "0.1"
toml = "0.7"
tera = "1.13"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need tera?

@@ -86,7 +88,13 @@ pub async fn run(config: Config, mut api: CommonApi) -> Result<()> {

widget.set_values(map!(
"icon" => Value::icon(api.get_icon("time")?),
"timestamp" => Value::datetime(Utc::now(), timezone.copied())
"timestamp" => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this will be a regression of #1723

let datetime: DateTime<Utc> = Utc::now();
let format: Option<&str> = Some("%a %e{S} %B, %H:%M");

Value::datetime(datetime, timezone, Some(format))
Copy link
Collaborator

@bim9262 bim9262 Mar 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third parameter would be Option<Option<&str>>, which probably isn't what you want.

@@ -104,11 +112,3 @@ pub async fn run(config: Config, mut api: CommonApi) -> Result<()> {
}
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaxVerevkin we need this to be able to get the timezone if the user change /etc/localtime, right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. @virajbhartiya added use libc::tzset, but I can't find it in libc docs?

@@ -81,6 +82,12 @@ pub fn new_formatter(name: &str, args: &[Arg]) -> Result<Box<dyn Formatter>> {
.error("Interval must be a positive number")?,
);
}
"padding" => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this code is part of the wrong PR.

@ammgws
Copy link
Collaborator

ammgws commented Mar 14, 2023

Not really sure what is happening here, but just to make sure - the original issue was to add support for formatting the number of the day of the month with the appropriate suffix such as st, nd, and rd (e.g. 1st, 2nd, 3rd).

Also the format string for the time block already had a breaking change in the upgrade to v0.30, so we shouldn't make anymore breaking changes especially not for a niche feature such as this one.

//! full = " $icon $timestamp.datetime(f:'%a %Y-%m-%d %R %Z', l:fr_BE) "
//! short = " $icon $timestamp.datetime(f:%R) "
//! full = " $icon $timestamp.datetime(f:'%a %e{S} %B, %H:%M', l:Europe/Lisbon) "
//! short = " $icon $timestamp.datetime(f:%R, l:Europe/Lisbon) "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: is for locale, not timezone

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these changes even necessary?

@ammgws ammgws marked this pull request as draft March 17, 2023 14:33
@virajbhartiya virajbhartiya closed this by deleting the head repository Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ordinals support to time block
4 participants