Coder Social home page Coder Social logo

timeprint's Introduction

Here's my stuff. Feel free to ask questions or log issues.

Books

Site Description
raytracing.github.io The Ray Tracing in One Weekend book series. Three online books (with source) on how to write your own raytracer

Tools

Repo Description
calendar Windows command-line tool to print specific months or years
csub Command substitution for the Windows command line
drives Windows command-line tool to display all current drive information
eol Windows command-line filter to convert End-Of-Line character sequences
ftimecomp Windows command-line tool for the comparison of file timestamps
hex Windows command-line hexadecimal dump utility
pathmatch Windows command-line tool to print directories and files matching wildcard specifications of arbitrary depth.
timeprint Nice Windows command-line tool to very flexibly print elapsed, relative or absolute times and dates
win-scripts A collection of useful Windows CMD scripts and fragments

Experimental / Miscellaneous

Repo Description
fpWorkbench A set of C++ programs for experimenting with floating point numbers
gibber I have a personal Perl script to generate English-like gibberish (for password inspiration). Someday I hope to port this to multiple platforms as a C++ tool.
hollasch Magical repository that allows me to have a profile README
jumpdir Sigh. Someday I'll get to this V2 port of a very awesome tool I wrote years ago.
LSON Needs a better name. Yet another rethinking of JSON, with tables, graphs, and much better freedom for expressing arbitrary data types.
pi-lab Archive of some Raspberry Pi Python scripts I wrote a while ago.
ray4 Source + doc of my master's thesis Four-Space Visualization of 4D Objects. 4D raytracer.
srhlab Random fragments and notes to document various programming concepts I've learned.

timeprint's People

Contributors

hollasch avatar

Watchers

 avatar  avatar

timeprint's Issues

Switch to new time reporting semantics: two times = diff, one time = explicit

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."

Delta time formats need a way to specify leading zeros

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.

Add `--delta` option

To enter a single-valued time delta, in ISO 8601 format. Note that this precludes any other time values on the command line.

Revise timeprint help header

Change to something like this:

timeprint v2.1.1 - Prints time and date information
https://github.com/hollasch/timeprint

<remainder of help text>

Use std::string instead of C char buffers

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.

Add options for simple elapsed time printing

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.

Review elapsed time formats

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.

Break up help output

The help output is 182 lines and growing. The --help command should take multiple arguments to subsets of the help documentation. Suggested subsets:

  • no args — Main short usage info
  • timezone — Supported time zone formats
  • format — Format codes
  • examples — Helpful examples

Add output comparitive tests

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.

Release v2.0.0

After the latest changes, release the updated version.

Add `--time` option to specify an explicit time

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

feature: alternate format codes

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.

Revisit delta time 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

Low-precision times should zero unspecified fields

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.

Provide a way for the TIMEFORMAT environment variable to also specify a delta time format

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?

Update README

The README file is now out of date with reality. Bring it up to date.

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.