Skip to content

Commit

Permalink
Timezone setting defined & javascript helper function added for conve…
Browse files Browse the repository at this point in the history
…rting datetime to another timezone #936
  • Loading branch information
ismcagdas committed Apr 19, 2016
1 parent f9fc933 commit 01a9ce4
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Abp.Web.Resources/Abp/Framework/scripts/abp.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,16 @@
};
})();

abp.timing.convertToLocalTime = function(targetTimeZoneOffset) {
var now = abp.clock.now();
var localTime = now.getTime();
var localOffset = now.getTimezoneOffset() * 60000;
var utc = localTime + localOffset;

var targetTime = utc + (3600000 * targetTimeZoneOffset);
return new Date(targetTime);
};

/* CLOCK *****************************************/
abp.clock = abp.clock || {};

Expand Down
2 changes: 2 additions & 0 deletions src/Abp/Abp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@
<Compile Include="Threading\Timers\AbpTimer.cs" />
<Compile Include="Threading\RunnableExtensions.cs" />
<Compile Include="Logging\IHasLogSeverity.cs" />
<Compile Include="Timing\TimingSettingNames.cs" />
<Compile Include="Timing\TimingSettingProvider.cs" />
<Compile Include="UI\Inputs\LocalizableComboboxItem.cs" />
<Compile Include="UI\Inputs\ILocalizableComboboxItem.cs" />
<Compile Include="UI\Inputs\ILocalizableComboboxItemSource.cs" />
Expand Down
1 change: 1 addition & 0 deletions src/Abp/Localization/Sources/AbpXmlSource/Abp-tr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
<text name="DefaultLanguage">Varsayılan dil</text>
<text name="ReceiveNotifications">Bildirimleri al</text>
<text name="CurrentUserDidNotLoginToTheApplication">Kullanıcı girişi yapılmamış!</text>
<text name="TimeZone">Zaman dilimi</text>
</texts>
</localizationDictionary>
1 change: 1 addition & 0 deletions src/Abp/Localization/Sources/AbpXmlSource/Abp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
<text name="DefaultLanguage">Default language</text>
<text name="ReceiveNotifications">Receive notifications</text>
<text name="CurrentUserDidNotLoginToTheApplication">Current user did not login to the application!</text>
<text name="TimeZone">Timezone</text>
</texts>
</localizationDictionary>
7 changes: 7 additions & 0 deletions src/Abp/Timing/TimingSettingNames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Abp.Timing
{
public static class TimingSettingNames
{
public const string TimeZone = "Abp.Timing.TimeZone";
}
}
22 changes: 22 additions & 0 deletions src/Abp/Timing/TimingSettingProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using Abp.Configuration;
using Abp.Localization;

namespace Abp.Timing
{
public class TimingSettingProvider : SettingProvider
{
public override IEnumerable<SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context)
{
return new[]
{
new SettingDefinition(TimingSettingNames.TimeZone, null, L("TimeZone"), scopes: SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true)
};
}

private static LocalizableString L(string name)
{
return new LocalizableString(name, AbpConsts.LocalizationSourceName);
}
}
}

0 comments on commit 01a9ce4

Please sign in to comment.