parseNumeric

Parse RPL_TOPICWHOTIME (aka RPL_TOPICTIME) numeric replies.

Format is 333 <user> <channel> <setter> <timestamp>

Examples

import std.datetime : DateTime, SysTime, UTC;
import std.range : only, takeNone;
{
	immutable result = parseNumeric!(Numeric.RPL_TOPICWHOTIME)(only("Someone", "#test", "Another!id@hostmask", "1496101944"));
	assert(result.get.channel == "#test");
	assert(result.get.setter.nickname == "Another");
	assert(result.get.setter.ident == "id");
	assert(result.get.setter.host == "hostmask");
	static immutable time = SysTime(DateTime(2017, 05, 29, 23, 52, 24), UTC());
	assert(result.get.timestamp == time);
}
{
	immutable badResult = parseNumeric!(Numeric.RPL_TOPICWHOTIME)(takeNone(only("")));
	assert(badResult.isNull);
}
{
	immutable badResult = parseNumeric!(Numeric.RPL_TOPICWHOTIME)(only("Someone"));
	assert(badResult.isNull);
}
{
	immutable badResult = parseNumeric!(Numeric.RPL_TOPICWHOTIME)(only("Someone", "#test"));
	assert(badResult.isNull);
}
{
	immutable badResult = parseNumeric!(Numeric.RPL_TOPICWHOTIME)(only("Someone", "#test", "Another!id@hostmask"));
	assert(badResult.isNull);
}
{
	immutable badResult = parseNumeric!(Numeric.RPL_TOPICWHOTIME)(only("Someone", "#test", "Another!id@hostmask", "invalidTimestamp"));
	assert(badResult.isNull);
}

Meta