Changed C# function to consider timezone, just like javascript