2017-06-12 11 views
-1

私は与えられた時間列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日付の情報ページから

+1

https://stackoverflow.com/questions/3675326/bash-subtracting-10-mins-from-a-given-time – jiveturkey

答えて

1

次作品:

$ date -d "14:00 5 minutes ago" +'%H:%M' 
13:55 

でも、私は理由を説明することはできません。

0

と、より意義が:

The time may alternatively be followed by a time zone correction, 
expressed as ‘SHHMM’, where S is ‘+’ or ‘-’, HH is a number of zone 
hours and MM is a number of zone minutes 

算術演算を実行するためにあなたの試みは失敗している、と日付が式を解析しようとしている「 - 5分の」タイムゾーン修正として。

関連する問題