pub fn parseYear4(text: *const [4]u8) !u16 text: *const [4]u8754
755
756
757
758
759
760
761
762
763
764
765
766pub fn parseYear4(text: *const [4]u8) !u16 {
const V = @Vector(4, u32);
const bytes: V = text.*;
const zero: V = @splat('0');
const mmmm: V = .{ 1000, 100, 10, 1 };
const d = bytes -% zero;
if (@reduce(.Or, d > @as(V, @splat(9)))) {
@branchHint(.unlikely);
return error.CertificateTimeInvalid;
}
const result = @reduce(.Add, d *% mmmm);
return @intCast(result);
}