Sha256: 26b8de212c7e17374a605c6dac53bb63a30c23bd1acd4698cbb40184d053b6fd

Contents?: true

Size: 622 Bytes

Versions: 382

Compression:

Stored size: 622 Bytes

Contents

#include <stdio.h>
#include "clock.h"

static void normalize_clock(int *hour, int *minute)
{
   while (*minute < 0) {
      *minute += 60;
      *hour -= 1;
   }
   *hour += *minute / 60;
   while (*hour < 0) {
      *hour += 24;
   }
   *hour %= 24;
   *minute %= 60;
}

void clock(time_text_t time_text, int hour, int minute)
{
   normalize_clock(&hour, &minute);
   sprintf(time_text, "%02d:%02d", hour, minute);
}

void clock_add(time_text_t time_text, int minute_offset)
{
   int hour;
   int minute;
   sscanf(time_text, "%02d:%02d", &hour, &minute);
   minute += minute_offset;
   clock(time_text, hour, minute);
}

Version data entries

382 entries across 382 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.118 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.117 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.116 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.115 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.114 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.113 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.111 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.110 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.109 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.108 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.107 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.106 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.105 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.104 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.103 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.102 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.101 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.100 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.99 tracks/c/exercises/clock/src/example.c