tAccept exposure time in seconds and MM:SS formats - filmtools - various tools for photographic film development and darkroom printing
(HTM) git clone git://src.adamsgaard.dk/filmtools
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 99c7415c82b752a70fd11953caf2d0cba95ec271
(DIR) parent cd326a387cf8e6498e123292bb996fe49893bcb0
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
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(-)
---
(DIR) 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 anders@adamsgaard.dk
(DIR) 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].manufacturer);
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 format");
+ }
+ }
sec_equiv = factor * pow(min * 60 + sec, exponent);
sec = (int)(sec_equiv) % 60;