It’s 4pm. Your Access is Denied.
08
January
The following defect was logged yesterday: Each day at 4pm PST our users are denied seamless access into [third party website].
Though I am sure the author of the code may be of another opinion, aren’t these types of defects kind of fun? They are like brain-teasers which you want to solve without looking at the answer — in this case is the code. As a bonus, you can bring these riddles home and share over dinner with family and friends. Everyone gets to play along.
Here’s the answer:
// Encryption uses GMT time in verifying timestamp. DateTime dtNow = DateTime.Now ; string sMonth = "0" + dtNow.Month.ToString() ; string sDay = "0" + dtNow.Day.ToString() ; // Do not make changes to hour when switching to daylight savings time. DateTime dtUTC = dtNow.ToUniversalTime(); string sHour = "0" + (dtUTC.Hour).ToString() ; string sMinute = "0" + dtNow.Minute.ToString() ; string sSecond = "0" + dtNow.Second.ToString() ; // timestamp t, in format "yyyymmddhhmmss" string sTimeStamp = dtNow.Year.ToString() + sMonth.Substring( ( ( sMonth.Length == 2 ) ? 0 : 1 ) , 2 ) + sDay.Substring( ( ( sDay.Length == 2 ) ? 0 : 1 ) , 2 ) + sHour.Substring( ( ( sHour.Length == 2 ) ? 0 : 1 ) , 2 ) + sMinute.Substring( ( ( sMinute.Length == 2 ) ? 0 : 1 ) , 2 ) + sSecond.Substring( ( ( sSecond.Length == 2 ) ? 0 : 1 ) , 2 ) ;



No comments yet.