Added addMinutesToTimestamp function
parent
140815cca4
commit
358b3bf4fc
|
@ -1,5 +1,6 @@
|
|||
const std = @import("std");
|
||||
const writer = std.io.getStdOut().writer();
|
||||
const writer = std.io.getStdOut().writer(); //rausnehmen
|
||||
|
||||
|
||||
const Timestamp = struct {
|
||||
hours: u64,
|
||||
|
@ -23,6 +24,7 @@ const pause_minutes: u64 = 2; // Länge der Pause zwischen 2 T
|
|||
|
||||
|
||||
pub fn main () !void {
|
||||
|
||||
var testStamp = Timestamp {
|
||||
.hours = 13,
|
||||
.minutes = 5,
|
||||
|
@ -33,14 +35,35 @@ pub fn main () !void {
|
|||
try printTimestamp(&testStamp);
|
||||
try writer.print("\n", .{});
|
||||
try printPlan();
|
||||
|
||||
try addMinutesToTimestamp(&testStamp, 175);
|
||||
try printTimestamp(&testStamp);
|
||||
}
|
||||
|
||||
// Printet timestamp im Format HH:MM
|
||||
pub fn printTimestamp(ts: *Timestamp) !void {
|
||||
try writer.print("{0d:0>2}:{1d:0>2}", .{ ts.hours, ts.minutes });
|
||||
|
||||
try writer.print("{0d:0>2}:{1d:0>2}", .{ ts.hours, ts.minutes });
|
||||
}
|
||||
|
||||
pub fn addMinutesToTimestamp(ts: *Timestamp, min: u16) !void{
|
||||
|
||||
var addHours: u64 = min / 60;
|
||||
var addMinutes: u64 = min%60;
|
||||
|
||||
|
||||
if ((addMinutes + ts.minutes) >= 60){
|
||||
addMinutes = (addMinutes + ts.minutes)%60;
|
||||
addHours += 1;
|
||||
}
|
||||
|
||||
ts.hours += addHours;
|
||||
ts.hours += addMinutes;
|
||||
|
||||
}
|
||||
|
||||
pub fn printPlan() !void {
|
||||
|
||||
const rand = std.crypto.random;
|
||||
|
||||
const noneNumber:u64 = number_of_testees+1;
|
||||
|
|
Loading…
Reference in New Issue