tShow number of hours for exposures longer than 60 mins - 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 fdf4f540757312f4e76e5eddbd95f5c2cb9e2691
 (DIR) parent e818b1a505a41603d281dfdaabd683053e824607
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Thu, 16 Jul 2020 22:36:50 +0200
       
       Show number of hours for exposures longer than 60 mins
       
       Diffstat:
         M reciprocity.c                       |      16 ++++++++++------
       
       1 file changed, 10 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/reciprocity.c b/reciprocity.c
       t@@ -47,7 +47,7 @@ int
        main(int argc, char **argv)
        {
                double exponent;
       -        int i, min, sec, sec_equiv;
       +        int i, hour, min, sec, sec_equiv;
        
                argv0 = *argv;
        
       t@@ -73,11 +73,15 @@ main(int argc, char **argv)
                if (sscanf(argv[2], "%d:%d", &min, &sec) != 2)
                        errx(2, "could not parse time in MM:SS format");
        
       -        sec_equiv = pow(min*60 + sec, exponent);
       -
       -        printf("%d:%02d\n",
       -               (int)(sec_equiv/60.0),
       -               (int)(sec_equiv)%60);
       +        sec_equiv = pow(min * 60 + sec, exponent);
       +    sec = (int)(sec_equiv) % 60;
       +        if ((min = (int)(sec_equiv / 60.0)) >= 60) {
       +                hour = (int)(min/60.0);
       +                min -= (int)(hour*60.0);
       +                printf("%d:%02d:%02d\n", hour, min, sec);
       +        } else {
       +                printf("%d:%02d\n", min, sec);
       +        }
        
                return 0;
        }