View Single Post
Old 02-15-2017, 03:55 PM   #30
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by Hanspeter View Post
Yep, it gives me the twelve hour time too. But what I need is a statement that gives on my Kindel (witch is set to 24Hour clock, not AM/PM) the 24 Hour time without seconds and on an other Kindle that is set to 12 AM/PM hour clock the 12 hour time including AM/PM.

From my point of view I have three possibilities:
1) I would need to find a way to tell the date statement to decide this on the fly
2) Add an If to the statement and use a different format string depending on the result
3) Add an If statement and duplicate all versions of the may statement with different format stings.

Version 3 would be the easiest, but I do not like that stile of coding to simply multiply all lines on the same call only with a small different template.

I think date +%X gives me what I need, but I would need some awk or sed command around it to remove the seconds:
Code:
~$ date +%X
19:32:13
I would expect that you would get '07:32:13 PM'

Hape
The date command does not work that way, it is reading a 64 bit number of microseconds.
Its output is not effected by how the GUI is displaying the time.

I have never programmed in Awk.

You could do it easy enough in Lua - It includes a system call with output formatting similar to the date command.
But being a full programming language, your not limited to the output format.

Lua is pre-installed on all touchscreen devices.
knc1 is offline   Reply With Quote