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

(exa PR) 1204: Support time zone settings for Windows #5

Closed
wants to merge 4 commits into from

Conversation

cafkafk
Copy link
Member

@cafkafk cafkafk commented Jul 29, 2023

@cafkafk cafkafk changed the title (exa PR) 1204 (exa PR) 1204: Support time zone settings for Windows Jul 29, 2023
@cafkafk cafkafk added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers looking for testers os › windows labels Jul 29, 2023
@cafkafk
Copy link
Member Author

cafkafk commented Jul 29, 2023

I don't have a windows box, and I'm not familiar with windows systems programming.

Need testers/reviewers that can verify this is working.

cargo test passes on my box Linux <hostname-redacted> 6.4.0 #1-NixOS SMP PREEMPT_DYNAMIC Sun Jun 25 23:29:58 UTC 2023 x86_64 GNU/Linux

@sbatial sbatial mentioned this pull request Jul 30, 2023
63 tasks
@cafkafk cafkafk removed enhancement New feature or request help wanted Extra attention is needed labels Jul 31, 2023
@cafkafk cafkafk marked this pull request as draft July 31, 2023 06:00
@cafkafk cafkafk added this to the exa pulls done milestone Jul 31, 2023
@daviessm
Copy link
Contributor

@cafkafk I'll have a look at this once #171 is merged. It also deletes Cargo.lock and adds it to .gitignore - not sure you want that to happen?

@cafkafk
Copy link
Member Author

cafkafk commented Aug 29, 2023

@cafkafk I'll have a look at this once #171 is merged. It also deletes Cargo.lock and adds it to .gitignore - not sure you want that to happen?

I don't at all, that's super odd

@agrmohit
Copy link

agrmohit commented Sep 6, 2023

This pr branch works perfectly for me on Windows 11
image

Edition	Windows 11 Pro
Version	22H2
Installed on	‎05-‎06-‎2023
OS build	22621.2215
Experience	Windows Feature Experience Pack 1000.22662.1000.0

@daviessm
Copy link
Contributor

daviessm commented Sep 6, 2023

@agrmohit could you try the branch from #58 (you might need to fix up a couple of conditional compilation problems) and see if that also works? It's a much simpler change for Windows than this one.

@agrmohit
Copy link

agrmohit commented Sep 6, 2023

I don't know rust and am unable to figure out how to resolve the compilation errors. Would be interested in testing it once those errors are resolved and also with resolving the errors. I have attached the output of cargo build below.

Details
❯ cargo build
   Compiling eza v0.10.9 (C:\Users\agrmo\projects\eza)
error[E0432]: unresolved import `self::users`
  --> src\output\render\mod.rs:35:15
   |
35 | pub use self::users::Render as UserRender;
   |               ^^^^^ could not find `users` in `self`

error[E0433]: failed to resolve: use of undeclared crate or module datetime
--> src\output\table.rs:365:9
|
365 | use datetime::zone::{FixedTimespan, FixedTimespanSet, StaticTimeZone, TimeZoneSource};
| ^^^^^^^^ use of undeclared crate or module datetime

error[E0432]: unresolved imports crate::output::render::GroupRender, crate::output::render::UserRender
--> src\output\table.rs:17:5
|
17 | GroupRender,
| ^^^^^^^^^^^ no GroupRender in output::render
...
21 | UserRender
| ^^^^^^^^^^
|
note: found an item that was configured out
--> src\output\render\mod.rs:13:59
|
13 | pub use self::groups::{Colours as GroupColours, Render as GroupRender};
| ^^^^^^^^^^^

error[E0412]: cannot find type SystemTime in this scope
--> src\fs\file.rs:485:42
|
485 | pub fn changed_time(&self) -> Option {
| ^^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
3 + use std::time::SystemTime;
|

error[E0425]: cannot find value users in this scope
--> src\output\table.rs:359:38
|
359 | Self { time_offset, numeric, users }
| ^^^^^ not found in this scope

error[E0412]: cannot find type TZResult in this scope
--> src\output\table.rs:364:29
|
364 | fn determine_time_zone() -> TZResult {
| ^^^^^^^^ help: an enum with a similar name exists: Result
|
::: C:\Users\agrmo.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\result.rs:502:1
|
502 | pub enum Result<T, E> {
| --------------------- similarly named enum Result defined here

warning: unused import: DisplayWidth
--> src\output\render\permissions.rs:6:37
|
6 | use crate::output::cell::{TextCell, DisplayWidth};
| ^^^^^^^^^^^^
|
note: the lint level is defined here
--> src\main.rs:7:9
|
7 | #![warn(unused)]
| ^^^^^^
= note: #[warn(unused_imports)] implied by #[warn(unused)]

error[E0599]: no method named uid found for struct std::fs::Metadata in the current scope
--> src\fs\file.rs:372:36
|
372 | Some(f::User(self.metadata.uid()))
| ^^^ method not found in Metadata

error[E0599]: no method named gid found for struct std::fs::Metadata in the current scope
--> src\fs\file.rs:383:37
|
383 | Some(f::Group(self.metadata.gid()))
| ^^^ method not found in Metadata

error[E0425]: cannot find function get_secattr in this scope
--> src\fs\feature\xattr.rs:107:38
|
107 | Ordering::Equal => return get_secattr(lister, &c_path),
| ^^^^^^^^^^^ not found in this scope

warning: use of deprecated method core::str::<impl str>::trim_left_matches: superseded by trim_start_matches
--> src\fs\feature\git.rs:334:62
|
334 | let normal_path = unc_path.as_os_str().to_str().unwrap().trim_left_matches("\\?\");
| ^^^^^^^^^^^^^^^^^
|
= note: #[warn(deprecated)] on by default
help: replace the use of the deprecated method
|
334 | let normal_path = unc_path.as_os_str().to_str().unwrap().trim_start_matches("\\?\");
| ~~~~~~~~~~~~~~~~~~

error[E0599]: no method named is_empty_dir found for reference &file::File<'_> in the current scope
--> src\output\icons.rs:109:17
|
109 | if file.is_empty_dir() {
| ^^^^^^^^^^^^ help: there is a method with a similar name: to_dir

error[E0599]: no variant or associated item named SecurityContext found for enum Column in the current scope
--> src\output\table.rs:106:34
|
106 | columns.push(Column::SecurityContext);
| ^^^^^^^^^^^^^^^ variant or associated item not found in Column
...
144 | pub enum Column {
| --------------- variant or associated item SecurityContext not found for this enum

error[E0560]: struct Environment has no field named users
--> src\output\table.rs:359:38
|
359 | Self { time_offset, numeric, users }
| ^^^^^ Environment does not have this field
|
= note: all struct fields are already assigned

error[E0423]: expected function, tuple struct or tuple variant, found trait TimeZone
--> src\output\table.rs:368:8
|
368 | Ok(TimeZone(TimeZoneSource::Static(&StaticTimeZone {
| ^^^^^^^^ not a function, tuple struct or tuple variant

error[E0599]: no method named permissions found for reference &file::File<'_> in the current scope
--> src\output\table.rs:452:14
|
452 | file.permissions().map(|p| f::PermissionsPlus {
| ^^^^^^^^^^^ method not found in &File<'_>
|
help: one of the expressions' fields has a method of the same name
|
452 | file.metadata.permissions().map(|p| f::PermissionsPlus {
| +++++++++

error[E0599]: no method named render found for enum Option in the current scope
--> src\output\table.rs:472:53
|
472 | self.permissions_plus(file, xattrs).render(self.theme)
| ^^^^^^ method not found in Option<PermissionsPlus>
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following traits define an item render, perhaps you need to implement one of them:
candidate #1: PermissionsPlusRender
candidate #2: RenderPermissions
candidate #3: times::Render
candidate #4: octal::Render

warning: unused import: OctalPermissionsRender
--> src\output\table.rs:18:5
|
18 | OctalPermissionsRender,
| ^^^^^^^^^^^^^^^^^^^^^^

warning: unused import: PermissionsPlusRender
--> src\output\table.rs:19:5
|
19 | PermissionsPlusRender,
| ^^^^^^^^^^^^^^^^^^^^^

error[E0433]: failed to resolve: use of undeclared crate or module lister
--> src\fs\feature\xattr.rs:97:28
|
97 | pub fn list_attrs(lister: &lister::Lister, path: &Path) -> io::Result<Vec> {
| ^^^^^^ use of undeclared crate or module lister

Some errors have detailed explanations: E0412, E0423, E0425, E0432, E0433, E0560, E0599.
For more information about an error, try rustc --explain E0412.
warning: eza (bin "eza") generated 4 warnings
error: could not compile eza (bin "eza") due to 16 previous errors; 4 warnings emitted

@daviessm
Copy link
Contributor

daviessm commented Sep 6, 2023

I don't know rust and am unable to figure out how to resolve the compilation errors. Would be interested in testing it once those errors are resolved and also with resolving the errors. I have attached the output of cargo build below.

Details

No worries, if @ariasuni doesn't get around to it first I'll make a branch for you tomorrow (life permitting).

@daviessm
Copy link
Contributor

daviessm commented Sep 7, 2023

@agrmohit can you try this branch: https://github.com/daviessm/eza/tree/pr-867? It's the same as the pr-867 branch but fixes the build on Windows.

@agrmohit
Copy link

agrmohit commented Sep 7, 2023

Doesn't work for me. Notice the time of file named this-file-was-created-at-19-43.txt
My timzone offset from UTC is +5:30
image

@daviessm
Copy link
Contributor

daviessm commented Sep 7, 2023

Doesn't work for me. Notice the time of file named this-file-was-created-at-19-43.txt My timzone offset from UTC is +5:30 !

Ok, I'll do some more fiddling. I don't use eza on Windows myself but I seem to be looking after the build for now!

@daviessm
Copy link
Contributor

daviessm commented Sep 7, 2023

I can't reproduce this. My local time zone is GMT but we're in summer time so UTC+1. I created a file, checked its time, set my computer to be in Singapore (UTC+8), created a new file, ran the test again and finally set the clock back to UTC+1. All of them worked.:
image
Same with IST. In fact it all works on the main branch as well, prior to the chrono changes. For some reason eza on your computer is using UTC for its times. @agrmohit What does Get-TimeZone in PowerShell tell you?

@agrmohit
Copy link

agrmohit commented Sep 7, 2023

I rechecked everything and realised I forgot to switch to the pr-867 branch before building it despite my terminal putting it right in front of me. Now its working as expected. Sorry about that.
image

@daviessm
Copy link
Contributor

daviessm commented Sep 7, 2023

Awesome, thanks! Closing in favour of #58

@daviessm daviessm closed this Sep 7, 2023
@cafkafk cafkafk deleted the pr-1204 branch September 12, 2023 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants