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.180 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.179 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.178 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.177 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.176 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.175 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.174 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.173 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.172 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.171 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.170 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.169 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.167 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.166 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.165 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.164 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.163 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.162 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.161 tracks/c/exercises/clock/src/example.c
trackler-2.2.1.160 tracks/c/exercises/clock/src/example.c