Saturday, January 28, 2012

Converting UTC DateTime to local timezone in WP7

I'm currently using the following to convert a DataTime know to be in NZST to NZDT when applicable. I.e. The code will automatically determine if daylight savings should be applied.

    public static DateTime DateTimeFromNzst(DateTime nzstDateTime)
    {
        // Known offset from UTC
        TimeSpan nzstOffset = new TimeSpan(12, 0, 0);
        DateTimeOffset dateTimeOffset = new DateTimeOffset(nzstDateTime, nzstOffset);
        DateTimeOffset dateTimeOffsetConvertedToLocal = TimeZoneInfo.ConvertTime(dateTimeOffset, TimeZoneInfo.Local);
        return dateTimeOffsetConvertedToLocal.DateTime;
    }

It should also be possible to convert from UTC to the local timezone by adjusting the known UTC offset to 0.

    public static DateTime DateTimeFromUtc(DateTime utcDateTime)
    {
        // Known offset from UTC
        TimeSpan utcOffset = new TimeSpan();
        DateTimeOffset dateTimeOffset = new DateTimeOffset(utcDateTime, utcOffset);
        DateTimeOffset dateTimeOffsetConvertedToLocal = TimeZoneInfo.ConvertTime(dateTimeOffset, TimeZoneInfo.Local);
        return dateTimeOffsetConvertedToLocal.DateTime;
    }

Friday, January 13, 2012

Salesforce Inbound Change Sets Deploy Error - organization's administration setup lock

During the validation and deployment of an inbound change set into a Salesforce production organisation I often run into the following issue.

I'll start either the validation or deployment action, wait awhile for the spin wheel to complete and then get a failed result.

The failure reason will be given as:

API Name: Deploy Error
Problem: The changes you requested require salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for the previous action to finish, then try again later.

If I wait for a period of time without any further action another deployment history will appear with the actual results of the action I started. It's like the deployment action splits off at some point and shows as both a failure due to the org admin setup lock and then later a success when it actually completes.