Comments (11)
Okay, here's where this gets dicey: how complex are you hoping the sufficies to be?
e.g., are you hoping to be able to say -x 3h22m12s
, -x 3.75h
or will allowing only whole numbers and a single suffix be sufficient?
If the restriction of a single suffix and an integer value is acceptable, then this does not bother me at all, and it should not take long to implement. If you are hoping for more complex values, this could be a rabbit-hole of parsing.
from pbpst.
A single suffix and integer is enough for my usages.
For more complex sunsets like -x 3.75h
-x $(bc <<< "3.75 * 60 ^ 2"
could be used — which does print it as a float; I'm unsure if pbpst
truncates to int. If it doesn't, perhaps it could ignore the floating part (e.g. interpret 3.75
as 3
) instead of having to create a trivial wrapper script?
from pbpst.
It should, at the moment, truncate (we use scanf()
).
One other consideration: I suspect the sufficies I will support will be the following: d(ays)
, h(ours)
, m(inutes)
, s(econds)
.
However, all of the sufficies (other than seconds) would actually just be a shortcut for seconds (e.g., 1d == 86400s
which is not, strictly speaking, true). Is that amenable? Dealing with time in an accurate fashion is incredibly difficult, so it should just be known that these units are not “correct”, they are just shorthand for seconds.
from pbpst.
I'm not entirely use what you mean. A day (and night) is 24 which is 24 * 60 ^ 2 == 86400s
; is that not accurate?
from pbpst.
Not quite; things like leap seconds tend to throw a wrench in the mix.
For a list of things that devs often assume incorrectly about time, see this article.
from pbpst.
I see. Well, I'm okay with that caveat.
from pbpst.
All right; in that case, this should not be difficult to do.
from pbpst.
@tmplt, a20ed59 adds this functionality.
It scans for a double, but casts to an int, so it will truncate the value; in addition, it only checks for a single character, which means anything following that is ignored.
$ pbpst -S#f somefile -x 5m
This means that the above will set a sunset 300 seconds into the future and is exactly the same as this:
$ pbpst -S#f somefile -x 5.7min
Finally, to remain backwards compatible, and to gracefully fallback to something sensible, if you pass an unexpected unit, or you pass no unit at all, pbpst
assumes you meant seconds.
Can you test this and make sure it works the way you expect? I will then document it and close the issue.
from pbpst.
It works as expected. Thank you!
from pbpst.
Good to hear it. I am going to change a bit of the implementation to be safer (casting from a double
to an int
without a few checks is a BadIdea™), and simpler (deduplicating some code). But it should not change the behavior.
I will push the documentation and updates tonight.
from pbpst.
ad45d65 closes this issue.
@tmplt, one extra thing to note; I changed the cast to unsigned
to take place a moment later which means that instead of truncating the count before the multiplier, it will truncate afterwards.
i.e., 5.5m == 330
rather than 300
. I would suspect this is actually preferred,
from pbpst.
Related Issues (20)
- pbpst says "Paste deleted" even when you pass it a silly UUID
- doc/pbpst.rst line 220+225 indentation errors? HOT 1
- Passing --provider and URL without the '/' suffix gives an invalid link HOT 2
- Allow files bigger than 64MiB HOT 9
- i18n HOT 6
- Provide an option to add pastes to the DB HOT 1
- Errors on use of stderr HOT 5
- Use of non-Async-Signal-Safe functions in signal handler
- Does it support authentication HOT 5
- Failing to build on x64 Linux with clang 3.9.1 HOT 1
- UUID HOT 10
- Issue on Musl HOT 1
- Could not create paste: HTTP response code said error HOT 9
- Don't use tup HOT 1
- Conditionally use sys/syslimits.h for macOS HOT 1
- pbpst does not work with stdin HOT 6
- Behaviour when re-creating a paste with sunset after manually removing it HOT 2
- How can I build a static pbpst
- Request for new release HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pbpst.