Share via


SPRegionalSettings.FirstWeekOfYear property

Gets or sets the first week of the year used in calendars on the server.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Property FirstWeekOfYear As Short
    Get
    Set
'Usage
Dim instance As SPRegionalSettings
Dim value As Short

value = instance.FirstWeekOfYear

instance.FirstWeekOfYear = value
public short FirstWeekOfYear { get; set; }

Property value

Type: System.Int16
A 16-bit integer that specifies the first week of the year.

Remarks

The FirstWeekOfYear property throws an exception if the value is not between 0 and 2.

Examples

The following code example sets the first week of the year to be the first full week of the year.

Dim siteCollection As New SPSite("https://localhost")
Try
    Dim rootWebSite As SPWeb = siteCollection.RootWeb
    Dim regionalsettings As SPRegionalSettings = rootWebSite.RegionalSettings
    regionalsettings.FirstWeekOfYear = 1

    rootWebSite.Update()
    rootWebSite.Dispose()
Finally
    siteCollection.Dispose()
End Try
using (SPSite oSiteCollection = new SPSite("https://localhost"))
{
    using (SPWeb oWebsiteRoot = oSiteCollection.RootWeb)
    {
        SPRegionalSettings oRegionalSettings = oWebsiteRoot.RegionalSettings;
        oRegionalSettings.FirstWeekOfYear = 1;
        oWebsiteRoot.Update();
    }
}

Note

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

See also

Reference

SPRegionalSettings class

SPRegionalSettings members

Microsoft.SharePoint namespace