use fmt;
use time;
use os;
use strconv;
use strings;

export fn main() void = {
	if (len(os::args) != 2) {
		os::exit(os::status::FAILURE);
	};

	let timestr = os::args[1];
	let i = time::now(time::clock::REALTIME);
	let spl = strings::split(timestr, ":");
	defer free(spl);

	let li = if (len(spl) > 2) {
		fmt::fatal("Duration format: m or m:s");
	} else if (len(spl) == 2) {
		let m = strconv::stoi64(spl[0])!;
		let s = strconv::stoi64(spl[1])!;
		let d = (m * time::MINUTE) + (s * time::SECOND);
		yield time::add(i, d);
	} else {
		let m = strconv::stoi64(spl[0])!;
		let d = m * time::MINUTE;
		yield time::add(i, d);
	};

	fmt::printfln("<t:{}:R>", time::unix(li))!;
};
