Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
back to 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kasthack committed Nov 6, 2015
1 parent 8a90ff8 commit 3e56575
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override object ReadJson( JsonReader reader, Type objectType, object exis
var jsonValue = serializer.Deserialize<JValue>(reader);
switch ( jsonValue.Type ) {
case JTokenType.Integer:
var dto = DateTimeOffset.FromUnixTimeSeconds( jsonValue.Value<long>() );
var dto = DateTimeOffsetHelper.FromUnixTimeSeconds( jsonValue.Value<long>() );
if ( objectType == DateTimeOffsetType || ( objectType.IsNullable() && Nullable.GetUnderlyingType( objectType ) == DateTimeOffsetType ) )
return dto;
return dto.LocalDateTime;
Expand Down
17 changes: 17 additions & 0 deletions Sources/kasthack.vksharp/Internal/DateTimeOffsetHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;

namespace kasthack.vksharp.Internal {
public static class DateTimeOffsetHelper {

private static readonly DateTimeOffset sTime = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);

public static int ToUnixTimeSeconds(this DateTimeOffset offset) {
return (int) (offset - sTime).TotalSeconds;
}

public static DateTimeOffset FromUnixTimeSeconds(long seconds) {
return sTime.AddSeconds(seconds);
}

}
}
2 changes: 1 addition & 1 deletion Sources/kasthack.vksharp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.6.1.*")]
[assembly: AssemblyVersion("0.6.3.*")]
[assembly: AssemblyFileVersion("1.0.0.0")]
8 changes: 5 additions & 3 deletions Sources/kasthack.vksharp/kasthack.vksharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>kasthack.vksharp</RootNamespace>
<AssemblyName>kasthack.vksharp</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -215,6 +216,7 @@
<Compile Include="Internal\Converters\SnakeCaseContractResolver.cs" />
<Compile Include="Internal\Converters\SnakeCaseEnumConverter.cs" />
<Compile Include="Internal\Converters\UnixTimeConverter.cs" />
<Compile Include="Internal\DateTimeOffsetHelper.cs" />
<Compile Include="Internal\MiscTools.cs" />
<Compile Include="Internal\MorozovHandler.cs" />
<Compile Include="Internal\ProxyPoolingHttpClientHandler.cs" />
Expand All @@ -228,8 +230,8 @@
<Compile Include="Token.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="favicon.ico" />
<Content Include="Generated\AllMethods.txt" />
<None Include="favicon.ico" />
<None Include="Generated\AllMethods.txt" />
<None Include="Generated\Methods.xml">
<SubType>Designer</SubType>
</None>
Expand Down

0 comments on commit 3e56575

Please sign in to comment.