SharePoint 2013: Calendar view issue using xsltlistviewwebpart

I was adding various lists on pages using XsltListViewWebPart as shown in the code below:
public static void AddXsltListViewWebPartToPage(SPLimitedWebPartManager wpm, string listName, 
    string viewName, string zoneId, int zoneIndex, bool isServerRender,  SPWeb web)
    SPList l = web.Lists[listName];
    XsltListViewWebPart xsltWp = new XsltListViewWebPart();
    xsltWp.ListName = l.ID.ToString("B").ToUpper();
    xsltWp.ViewGuid = l.Views[viewName].ID.ToString("B").ToUpper();                
    wpm.AddWebPart(xsltWp, zoneId, zoneIndex);
However, the Calendar view of a Calendar list was not getting applied using this code. I found that if XsltListViewWebPart is modified through UI and calendar view is applied; the Calendar view gets applied properly. When I opened the page using SharePoint Designer I found that the webpart had changed to ListViewWebPart.
So, the code had to be modified to use ListViewWebPart as shown:
SPList l = web.Lists[listName];
ListViewWebPart lvwp = new ListViewWebPart();
lvwp.ListName = l.ID.ToString("B").ToUpper();
lvwp.ViewGuid = l.Views[viewName].ID.ToString("B").ToUpper();
wpm.AddWebPart(lvwp, zoneId, zoneIndex);