Ray intersection with Sun positions throughout the year
The function that calculates sun position in the sky takes as input
local latitude, longitude and local date time. The output is a vector 
which is sun position:



Inversing the above means using the ray direction(sun position in the sky) and retrieving back the local date time. If the date time is valid then the ray must hit the sun path throughout the year. 

Here is the inverse function of the above:

public DateTime GetLocalDatetime(double haSolar, double vaSolar)
{
    double latitude = Helper.ToRadian(Latitude);
    double longitude = Helper.ToRadian(Longitude);

    double zenithTheta = Helper.PiOver2 - vaSolar;

    double sinSolarDeclination = (Math.Cos(Math.PI - haSolar) * Math.Cos(latitude) * Math.Sin(zenithTheta)) + Math.Sin(latitude) * Math.Cos(zenithTheta);
    double solarDeclination = Math.Asin(sinSolarDeclination);

    double cosH = (Math.Sin(vaSolar) - Math.Sin(latitude) * sinSolarDeclination) / (Math.Cos(latitude) * Math.Cos(solarDeclination));
    if (Math.Abs(cosH) &gt; 1) return DateTime.MinValue;

    double H = Math.Acos(cosH);
    if (haSolar &lt; 0) H *= -1;

    double declratio = solarDeclination / Helper.ToRadian(23.45);
    if (Math.Abs(declratio) &gt; 1) return DateTime.MinValue;

    double beta = Math.Asin(declratio);
    int n = (int)Math.Round(beta / Helper.ToRadian(360d / 365d) + 81d, 1);

    DateTime localtime = new DateTime(DateTime.Now.Year, 1, 1).AddDays(n - 1);
    DateTime solartime = new DateTime(localtime.Year, localtime.Month, localtime.Day, 12, 0, 0);
    solartime = solartime.AddMinutes(4 * Helper.ToDegree(H));

    double eot = 9.87 * Math.Sin(2d * beta) - 7.53 * Math.Cos(beta) - 1.5 * Math.Sin(beta);
    double deltatimezone = 4d * (longitude - (Timezone * 15d));
    return solartime.AddMinutes(-(eot + deltatimezone));
}


And the image where each band represent each month in the year: