私は与えられた時間列14:00
を持っていて、5分を減算したいと思います。 これはどのようにしてbashで行うことができますか?与えられた時間から分を引く方法は?
は私にdatetimeオブジェクトを与える:date -d "14:00" +'%H:%M'
- >14:00
私は減算を試してみました:date -d "14:00 - 5min" +'%H:%M'
- >は21:01
を与えます。しかし、なぜ?
もちろん、希望の結果:13:55
。
Our units of temporal measurement, from seconds on up to months,
are so complicated, asymmetrical and disjunctive so as to make
coherent mental reckoning in time all but impossible. Indeed, had
some tyrannical god contrived to enslave our minds to time, to make
it all but impossible for us to escape subjection to sodden
routines and unpleasant surprises, he could hardly have done better
than handing down our present system. It is like a set of
trapezoidal building blocks, with no vertical or horizontal
surfaces, like a language in which the simplest thought demands
ornate constructions, useless particles and lengthy
circumlocutions. Unlike the more successful patterns of language
and science, which enable us to face experience boldly or at least
level-headedly, our system of temporal calculation silently and
persistently encourages our terror of time.
—Robert Grudin, ‘Time and the Art of Living’.
:GNU日付の情報ページから
https://stackoverflow.com/questions/3675326/bash-subtracting-10-mins-from-a-given-time – jiveturkey