Code Monkey home page Code Monkey logo

Comments (5)

malxau avatar malxau commented on July 26, 2024

I dug into this a little, but think I should set expectations: CMD isn't doing what the rest of Windows is doing. It's always including leading zeroes to help alignment, even though leading zeroes are part of the locale settings and are generally not used elsewhere. This means CMD is left trying to reconstruct strings based on individual locale primitives (see GetLocaleInfo) rather than just let the system format things (as in GetDateFormat).

I'm heading down the same path, but because it's different and needs to be aware of every locale setting to be accurate, it will likely always be a little bit quirky.

from yori.

malxau avatar malxau commented on July 26, 2024

I pushed a change to master to use locale aware settings for time and date. As noted above, this isn't ideal: it currently covers five elements:

  • Date separator character
  • Time separator character
  • Date field order
  • Two or four character years
  • 24 hour or 12 hour time

Looking at the other tools, sdir might want to adopt the first two or three, but since its goal is to be compact I don't think 12 hour time would work well there. Finfo is really leaving the user in control of specifying the format string. I can't think of anything else that deals in times and dates.

from yori.

aleaksunder avatar aleaksunder commented on July 26, 2024

Just want to know... Can this locale-awareness may break Yori's scripts universality?
We know that cmd.exe locales broke so many opportunities to write really universal scripts which would work on every system and every locale! For example date and time commands outputs in user-locale format, so we don't have opportunity to grab seperate year from that output and be sure that our code will work on every system and locale

You could just carefully look at theese links:
https://www.robvanderwoude.com/datetimentparse.php
https://ritchielawrence.github.io/batchfunctionlibrary
https://ss64.com/nt/syntax-getdate.html

I just want to point that the cmd's locale awareness just put all of scipters in situation where this is completely impossible to write script that get such a little thing as get current date in bullet-proof manner... This was discusting to not be able to do so!

AFAIK now Yori support output in English locale formats and this makes it predictable and reliable... Please do not set locale dependency by default... because we have some fantastic languages like Turkish, Chineese and Japanese where things go completely wrong way as in English one!

Or at least make an option for locale-awareness like command line parameter or maybe ini file parameter

from yori.

malxau avatar malxau commented on July 26, 2024

That's a very valid concern and I had the same concern. Just to note a few things:

  • Commands line date and finfo output data points in a caller-specified format. This was an attempt to make life better for scripts; rather than output text and have a script try to parse it, it allows the output to be in the form the script wants. Those commands are not changing.
  • Following on from the above, commands like dir or sdir seem like horrible things for scripts to parse, so my focus is on ensuring other tools are available for scripts.
  • The behavior here is optional and can be disabled with -g.

I totally agree with your high order point that, one way or another, there should be output that is easy for scripts to consume.

from yori.

malxau avatar malxau commented on July 26, 2024

I just released 1.21 which I believe fixes this issue. You can upgrade an existing install with ypm -u. If you find any additional problems, please either reopen this issue or file a new one describing that problem. Thanks for the report!

from yori.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.