tAccept exposure time in seconds and MM:SS formats - filmtools - various tools … | |
git clone git://src.adamsgaard.dk/filmtools | |
Log | |
Files | |
Refs | |
--- | |
commit 99c7415c82b752a70fd11953caf2d0cba95ec271 | |
parent cd326a387cf8e6498e123292bb996fe49893bcb0 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 16 Jul 2020 23:02:48 +0200 | |
Accept exposure time in seconds and MM:SS formats | |
Diffstat: | |
M reciprocity.1 | 2 +- | |
M reciprocity.c | 11 ++++++++--- | |
2 files changed, 9 insertions(+), 4 deletions(-) | |
--- | |
diff --git a/reciprocity.1 b/reciprocity.1 | |
t@@ -44,7 +44,7 @@ tmz | |
trix | |
.El | |
.It Ar time | |
-is metered exposure time in format MM:SS | |
+is metered exposure time in seconds or format MM:SS | |
.El | |
.Sh AUTHORS | |
.An Anders Damsgaard Aq Mt [email protected] | |
diff --git a/reciprocity.c b/reciprocity.c | |
t@@ -37,7 +37,7 @@ usage() | |
int i; | |
printf("usage: %s film time\n", argv0); | |
- puts("where time is metered exposure time in format MM:SS,"); | |
+ puts("where time is metered exposure time in seconds or format MM:SS,"… | |
puts("and film is one of the following:"); | |
for (i = 0; i < LENGTH(films); i++) | |
printf(" %-12s (%s)\n", films[i].name, films[i].manufacture… | |
t@@ -71,8 +71,13 @@ main(int argc, char **argv) | |
} | |
} | |
- if (sscanf(argv[2], "%d:%d", &min, &sec) != 2) | |
- errx(2, "could not parse time in MM:SS format"); | |
+ if (sscanf(argv[2], "%d:%d", &min, &sec) != 2) { | |
+ if (sscanf(argv[2], "%d", &sec) == 1) { | |
+ min = 0; | |
+ } else { | |
+ errx(2, "could not parse time in seconds or MM:SS form… | |
+ } | |
+ } | |
sec_equiv = factor * pow(min * 60 + sec, exponent); | |
sec = (int)(sec_equiv) % 60; |