Bug Confirmed by Wolfram Research
My time zone is GMT+8, which is used in this answer.
I can only explain how you get the incorrect answer.
First we need to read the definitions to trace the evaluation. The powerful tool I used is GeneralUtilities`PrintDefinitions
. I will just show the main steps.
First store that converted date object in t, t = TimeZoneConvert[Now,"GMT"]
.
Check what's inside
t//InputForm
DateObject[{2017, 3, 14},
TimeObject[{5, 58, 23.634473},
TimeZone -> "GMT"],
TimeZone -> "GMT"]
From the definitions of DayName
,
DataPaclets`CalendarDataDump`iDayName[t]
(*Monday*)
Then,
DataPaclets`CalendarDataDump`doDayName[t]
(*Monday*)
Then,
DataPaclets`CalendarDataDump`ToInternalDate[{"Gregorian", t}, DayName]
(*{"Gregorian", 2017, 3, 13, 21, 58, 23.6345}*)
Here we noticed that this function AGAIN subtracted 8 hours from the date, which is incorrect. Its code mainly contains two parts, the first is roughly
System`DateObjectDump`$tempDate = t;
System`DateObjectDump`correctTimeZoneOffset[
System`DateObjectDump`iObjectTimeZone[t]]
(*I added the first line to make the code works, otherwise it returns $Failed, I got the value of $tempdate from tracing*)
This returns 0
, which is the time zone for this date. The return value of this function is
DateList[Join[PadRight[date, 3, 1], First @ time], TimeZone -> tz]
which is
DateList[Join[PadRight[{2017, 3, 14}, 3, 1],
First @TimeObject[{5, 58, 23.634473}, TimeZone -> "GMT"]],
TimeZone -> 0]
in our case. Unfortunately, from the docs of DateList
DateList[TimeZone->z] gives the date and time inferred for time zone z by assuming that your computer is set for the time zone specified by $TimeZone. »
It is assuming the input, {2017, 3, 14, 5, 58, 23.6345}
is the local time, and converts it to TimeZone -> 0
, so then another 8 hours is subtracted from it, finally we get
{2017, 3, 13, 21, 58, 23.6345}