# DayName giving incorrect days with TimeZoneConvert

So I used TimeZoneConvert to get the time in GMT:

TimeZoneConvert[Now,"GMT"]


It outputs a date object that says Tuesday 14 March 2017 02:45:08 GMT.

But when I then try:

DayName @ TimeZoneConvert[Now, "GMT"]


I get Monday, even though the date object is a Tuesday. What's going on here?

• Can somebody with version 10.x add the customary header for bug posts, please? – J. M. will be back soon Mar 31 '17 at 5:10

## 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 GeneralUtilitiesPrintDefinitions. 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,

DataPacletsCalendarDataDumpiDayName[t]
(*Monday*)


Then,

DataPacletsCalendarDataDumpdoDayName[t]
(*Monday*)


Then,

DataPacletsCalendarDataDumpToInternalDate[{"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

SystemDateObjectDump$tempDate = t; SystemDateObjectDumpcorrectTimeZoneOffset[ SystemDateObjectDumpiObjectTimeZone[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}
`
• @numbermaniac of course. I have filled a support form. The case number is 3859858 – happy fish Mar 14 '17 at 8:15
• Awesome, thanks! – numbermaniac Mar 14 '17 at 8:20