hollasch / timeprint Goto Github PK
View Code? Open in Web Editor NEWPrint date and time information on the Windows command line
License: MIT License
Print date and time information on the Windows command line
License: MIT License
This is the '
prefix.
See #20.
Implement the lowercase letter prefix in a delta format code, which indicates a preceding modulus.
See #20 for more information.
It currently lists %_S
as elapsed whole seconds, but needs instead to refer to delta formats.
timeprint should be able to track the next greater unit automatically, left to right. Possibly try out a new experimental delta token that does this automatically. Try new delta symbol -
. This would yield the following syntax:
%-['kd][0]<U>[.[#]]
-v- v v --v-
Numeric Format --------' | | |
Optional leading zeros ----' | |
Units ------------------------' |
Decimal Precision -----------------'
How to handle the case where the next greater unit was equal or smaller than the current? Consider suppressing the interpretation of the current code (printing it literally), or insert an error indicator.
As an example, this:
timeprint --now --time 20181029T160000 %_Dd %_d0H:%_h0M:%_m0S
becomes this:
timeprint --now --time 20181029T160000 %-Dd %-0H:%-0M:%-0S
More intuitive and less error-prone. An sketch of an erroneous format string:
timeprint --now --time 20181029T160000 %-Dd %-0H:%-0D:%-0S
15d 23:<ERROR: %-0D>:2718
Keep --time now
; just add the new option -n
/--now
.
See https://en.wikipedia.org/wiki/Gregorian_calendar.
The Gregorian calendar was enacted 1582-10-15. Add code to support such dates. For delta display, we have room to use negative 64-bit values. This task is made easier by the fact that leap seconds didn't exist until 1972, so the calendar is predictable for that time period.
For non-delta values, this may not be simple.
timeprint --modTime
crashes.
After the latest changes, release the updated version.
-e
= --escapeChar
-m
= --modTime
-z
= --timezone
Help output line:
Command switches may be prefixed with a dash (-) or a slash (/).
This is incorrect; they can be a double dash or a slash.
Also ensure that the remaining %_s
option works according to the new delta time spec.
See #20.
Consider alternate format codes. For example,
"%Y-%m-%d"
could be
"{yr}-{min}-{day}"
Given the current abundance of format codes (43 at this point in time), doing any non-trivial task pretty much requires consulting the help.
One option is to specify the modification age of a file. Equivalent to
timeprint --modification <file> --now ...
A second improvement would be a simple, smart elapsed time format code. This would be in the format
%_Y, %_yD, %_Dh:%_h0M:%_m0S
In practice it would be a bit smarter than that, eliding large units with zero value. For example, if the total elapsed time was under a day, then elide years and days.
See issue #44.
Either introduce a new TIMEFORMATD (or TIMEFORMATDELTA) environment variable, or a way to specify default absolute and delta time formats in the existing TIMEFORMAT environment variable. For the latter option, try to choose some kind of separator before the second, delta, format (this is mostly backwards compatible). What would be a good separator in this case?
timeprint --timeZone
crashes.
These values are the floor of nominal years, tropical years, days, hours, minutes and seconds.
See #20.
Here's an example:
> timeprint --now --time 20181029T160000 %_Dd %_d0H:%_h0M:%_m0S
3d 05:13:30
> timeprint --now --time 20181029T1600 %_Dd %_d0H:%_h0M:%_m0S
3d 05:14:00
Notice that if the time here is specified as 1600, then the delta time uses the same precision for --now
, zeroing out the seconds. In this situation, a time of 1600 (or even 16) should be interpreted as 160000.
Too easy to have it drift from the current implementation, and too much work to continually convert from plaintext to markdown. Probably just capture plaintext in each session.
Y.
= Y.8
T.
= T.8
D.
= D.5
H.
= H.4
M.
= M.2
See #20.
Add a switch to take in a specified time in ISO 8601 format. This can be used as either the time to report, or as the two times for computing differences (this would require two such arguments).
> timeprint --time 1932-04-17 --now %_Y years, %_yD days.
48 years, 104 days
Lots of valid uses of timeprint are difficult to test with acceptance testing, since any time-varying outputs (like --now
) will change from run to run. Add utilities to redirect output to a file and then compare that output with the output from other runs. That would make it possible, for example, to test -n
and --now
. It could also be used to validate file access, creation, and modification times.
Currently, a time delta of "%_H:%_hM:%_mS"
may yield output like 22:1:5
. We need to support a field width specifier, and away to choose between padding with spaces and padding with zeros.
Equivalent to %Y-%m-%dT%H:%M:%S%z
.
To enter a single-valued time delta, in ISO 8601 format. Note that this precludes any other time values on the command line.
Currently %_s
(elapsed whole seconds), %_h
(elapsed whole hours) and %_d
(elapsed whole days) are the only fields that make much sense when reporting time differences.
Hours and days should be real-valued, with modifiers to control formatting. Likely, fractional formats should be truncated rather than rounded. For example, if half a day has elapsed, then 0 should be output. There should also be a way to report days-hours-minutes-seconds and others in a sensible way. Perhaps format controls could also specify whole modulo values for use in multi-value fields.
Design in this issue first.
All of the code for this tool is in a single monolithic function. Enough already.
Include the --help (-h) switch.
There seem to be some issues with setting unit values, with local versus UTC, and with properly accounting for time zone specification.
Change to something like this:
timeprint v2.1.1 - Prints time and date information
https://github.com/hollasch/timeprint
<remainder of help text>
For example, consider using ICU Datetime: http://userguide.icu-project.org/datetime
Implement the following syntax:
<timeValue> = now use current date + time + zone
<timeValue> = <date> time = current time
<timeValue> = <time> date = current date
<timeValue> = <date>T<time>
<date> = <YYYY>-?<MM>-?<DD>
<date> = <YYYY> month = current month, day = current day
<date> = <YYYY>-<MM> day = current day
<date> = --<MM>-?<DD> year = current year
<date> = <YYYY>-?<DDD>
<time> = <HH>:?<MM>:?<SS><zone>
<time> = <HH>:?<MM><zone> seconds = current seconds
<time> = <HH><zone> minutes = current minutes, seconds = current seconds
<zone> = <null> use current local time zone
<zone> = Z
<zone> = [+-]<HH>:?<MM>
<zone> = [+-]<HH>
-? = - | <null>
:? = : | <null>
+- = + | -
<YYYY> = 0000-9999
<MM> = 01-12
<DD> = 01-31
<DDD> = 001-366
<HH> = 00-24 24 = midnight / 00 of next day
<MM> = 00-59
<SS> = 00-60 Accomodates leap seconds
Report on the creation time of the named file.
The help output is 182 lines and growing. The --help
command should take multiple arguments to subsets of the help documentation. Suggested subsets:
If no format is specified, and if a delta time is computed, use a default format that generally works for deltas.
The old semantics were such that --modTime
reported the time elapsed since the modification time and now.
The new semantics will report the modification time explicitly (and access time and explicit time). If two times are supplied, then the difference will be reported.
So, for example, to get the old behavior of --modTime
, you'd do this:
timeprint --modTime someFile --time now "%_s seconds since someFile was modified."
The README file is now out of date with reality. Bring it up to date.
This suffixes the delta format with [.[#]]
. It should print the floor of the given number of digits, rather than rounding.
See #20.
timeprint --accessTime <fileName>
should use the access time of the named file.
See #20 for description. This is for the explicit characters; the locale-dependent character is another issue.
There are several latent issues where it's possible to have a buffer overflow in the code. Rather than fix these, the code should just be switched to std::string.
Just a script with expected outputs and a diff from accepted output should do it.
For a time diff of 10:04:08
, delta time formats would report 10:4:8
. Need to revisit the syntax to specify zero-padding of appropriate (manual or appropriate) width. Perhaps key off of next greater unit?
format | Leading zeros |
---|---|
y0D |
3 |
y0H |
4 |
y0M |
6 |
y0S |
8 |
d0H |
2 |
d0M |
4 |
d0S |
5 |
h0M |
2 |
h0S |
4 |
m0S |
2 |
Yup, I think that would be a nice solution.
%a
= %3a
Format | |||||||
---|---|---|---|---|---|---|---|
%3a |
Mon | Tue | Wed | Thu | Fri | Sat | Sun |
%2a |
Mo | Tu | We | Th | Fr | Sa | Su |
%1a |
M | T | W | T | F | S | S |
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.