diff --git a/Source/Kippt.sln b/Source/Kippt.sln
index f218bf5..392ca24 100644
--- a/Source/Kippt.sln
+++ b/Source/Kippt.sln
@@ -1,54 +1,66 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kippt", "Kippt\Kippt.csproj", "{2D95826E-EE1F-4417-AE71-2D492F25CC6E}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kippt.Silverlight", "Kippt.Silverlight\Kippt.Silverlight.csproj", "{7424C378-5F9B-4C5A-8190-92C25A28C915}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kippt.WindowsPhone", "Kippt.WindowsPhone\Kippt.WindowsPhone.csproj", "{AB64219C-EA63-4391-A9E1-27F4C9AF830C}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|Mixed Platforms = Debug|Mixed Platforms
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|Mixed Platforms = Release|Mixed Platforms
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Debug|x86.ActiveCfg = Debug|Any CPU
- {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Release|Any CPU.Build.0 = Release|Any CPU
- {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Release|x86.ActiveCfg = Release|Any CPU
- {7424C378-5F9B-4C5A-8190-92C25A28C915}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7424C378-5F9B-4C5A-8190-92C25A28C915}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7424C378-5F9B-4C5A-8190-92C25A28C915}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {7424C378-5F9B-4C5A-8190-92C25A28C915}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {7424C378-5F9B-4C5A-8190-92C25A28C915}.Debug|x86.ActiveCfg = Debug|Any CPU
- {7424C378-5F9B-4C5A-8190-92C25A28C915}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7424C378-5F9B-4C5A-8190-92C25A28C915}.Release|Any CPU.Build.0 = Release|Any CPU
- {7424C378-5F9B-4C5A-8190-92C25A28C915}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {7424C378-5F9B-4C5A-8190-92C25A28C915}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {7424C378-5F9B-4C5A-8190-92C25A28C915}.Release|x86.ActiveCfg = Release|Any CPU
- {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Debug|x86.ActiveCfg = Debug|Any CPU
- {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Release|Any CPU.Build.0 = Release|Any CPU
- {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Release|x86.ActiveCfg = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kippt", "Kippt\Kippt.csproj", "{2D95826E-EE1F-4417-AE71-2D492F25CC6E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kippt.Silverlight", "Kippt.Silverlight\Kippt.Silverlight.csproj", "{7424C378-5F9B-4C5A-8190-92C25A28C915}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kippt.WindowsPhone", "Kippt.WindowsPhone\Kippt.WindowsPhone.csproj", "{AB64219C-EA63-4391-A9E1-27F4C9AF830C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kippt.Tests", "Kippt.Tests\Kippt.Tests.csproj", "{4BD9A16D-591A-47B0-99FF-60F26AA176B8}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {2D95826E-EE1F-4417-AE71-2D492F25CC6E}.Release|x86.ActiveCfg = Release|Any CPU
+ {7424C378-5F9B-4C5A-8190-92C25A28C915}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7424C378-5F9B-4C5A-8190-92C25A28C915}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7424C378-5F9B-4C5A-8190-92C25A28C915}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {7424C378-5F9B-4C5A-8190-92C25A28C915}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {7424C378-5F9B-4C5A-8190-92C25A28C915}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {7424C378-5F9B-4C5A-8190-92C25A28C915}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7424C378-5F9B-4C5A-8190-92C25A28C915}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7424C378-5F9B-4C5A-8190-92C25A28C915}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {7424C378-5F9B-4C5A-8190-92C25A28C915}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {7424C378-5F9B-4C5A-8190-92C25A28C915}.Release|x86.ActiveCfg = Release|Any CPU
+ {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {AB64219C-EA63-4391-A9E1-27F4C9AF830C}.Release|x86.ActiveCfg = Release|Any CPU
+ {4BD9A16D-591A-47B0-99FF-60F26AA176B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4BD9A16D-591A-47B0-99FF-60F26AA176B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4BD9A16D-591A-47B0-99FF-60F26AA176B8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {4BD9A16D-591A-47B0-99FF-60F26AA176B8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {4BD9A16D-591A-47B0-99FF-60F26AA176B8}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {4BD9A16D-591A-47B0-99FF-60F26AA176B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4BD9A16D-591A-47B0-99FF-60F26AA176B8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4BD9A16D-591A-47B0-99FF-60F26AA176B8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {4BD9A16D-591A-47B0-99FF-60F26AA176B8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {4BD9A16D-591A-47B0-99FF-60F26AA176B8}.Release|x86.ActiveCfg = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Source/Kippt.suo b/Source/Kippt.suo
index 718ccbc..6fabfab 100644
Binary files a/Source/Kippt.suo and b/Source/Kippt.suo differ
diff --git a/Source/Kippt/KipptAccount.cs b/Source/Kippt/KipptAccount.cs
index b76351b..f6a152a 100644
--- a/Source/Kippt/KipptAccount.cs
+++ b/Source/Kippt/KipptAccount.cs
@@ -47,6 +47,12 @@ public class KipptAccount
[DataMember(Name = "api_token")]
public string ApiToken { get; set; }
+ ///
+ /// Gets the profile url.
+ ///
+ [DataMember(Name = "app_url")]
+ public string Profile { get; set; }
+
///
/// Gets or sets the avatar url (Gravatar).
///
diff --git a/Source/Kippt/KipptClip.cs b/Source/Kippt/KipptClip.cs
index b7d8d7a..6bccc7e 100644
--- a/Source/Kippt/KipptClip.cs
+++ b/Source/Kippt/KipptClip.cs
@@ -70,7 +70,7 @@ public class KipptClip
///
public DateTime DateCreated
{
- get { return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddMilliseconds(dateCreated * 1000L); }
+ get { return Utils.FromUnixTime(dateCreated); }
}
[DataMember(Name = "updated")]
@@ -80,7 +80,7 @@ public DateTime DateCreated
///
public DateTime DateUpdated
{
- get { return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddMilliseconds(dateUpdated * 1000L); }
+ get { return Utils.FromUnixTime(dateUpdated); }
}
[DataMember(Name = "list")]
diff --git a/Source/Kippt/KipptList.cs b/Source/Kippt/KipptList.cs
index cfaa9bd..296e492 100644
--- a/Source/Kippt/KipptList.cs
+++ b/Source/Kippt/KipptList.cs
@@ -1,182 +1,182 @@
-/*
- Kippt.NET Library for consuming Kippt APIs.
- Copyright (C) 2012 Haythem Tlili
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Runtime.Serialization;
-
-namespace Kippt
-{
- ///
- /// Lists are used to organize and categorize clips. Clips will have a list associated to them.
- /// Every user has two lists predefined, inbox and read-later, which can't be deleted.
- ///
- [DataContract]
- public class KipptList : KipptClient
- {
- #region Properties
-
- ///
- /// Gets list id.
- ///
- [DataMember(Name = "id")]
- public int Id { get; set; }
-
- ///
- /// Gets or sets list title.
- ///
- [DataMember(Name = "title")]
- public string Title { get; set; }
-
- ///
- /// Gets list slug.
- ///
- [DataMember(Name = "slug")]
- public string Slug { get; set; }
-
- [DataMember(Name = "created")]
- public int dateCreated;
- ///
- /// Gets the creation date of a list.
- ///
- public DateTime DateCreated
- {
- get { return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddMilliseconds(dateCreated * 1000L); }
- }
-
- [DataMember(Name = "updated")]
- public int dateUpdated;
- ///
- /// Gets the update date of a list.
- ///
- public DateTime DateUpdated
- {
- get { return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddMilliseconds(dateUpdated * 1000L); }
- }
-
- ///
- /// Gets the permalink of a list.
- ///
- [DataMember(Name = "resource_uri")]
- public string ResourceUri { get; set; }
-
- ///
- /// Gets the rss uri of a list.
- ///
- [DataMember(Name = "rss_url")]
- public Uri Rss { get; set; }
-
- #endregion Properties
-
- #region Public Methods
-
- ///
- /// Returns a list of clips associated to the list instance.
- ///
- ///
- ///
- /// Results are paginated.
- /// The default number of returned clips is 20.
- /// Pagination information are stored in the Meta property of class.
- ///
- public KipptClipCollection GetClips()
- {
- return KipptClip.GetClipsByList(this.Id, 100000);
- }
-
- ///
- /// Creates a kippt list.
- ///
- public void Create()
- {
- KipptApi.ApiAction(ApiCommand.Lists, HttpMethod.Post, JsonSerializer.Serialize(this));
- }
-
- ///
- /// Updates a kippt list.
- ///
- public void Update()
- {
- KipptApi.ApiAction(ApiCommand.List, HttpMethod.Put, JsonSerializer.Serialize(this), this.Id);
- }
-
- ///
- /// Deletes a kippt list.
- ///
- public void Delete()
- {
- KipptApi.ApiAction(ApiCommand.List, HttpMethod.Delete, this.Id);
- }
-
- #endregion Public Methods
-
- #region Shared Methods
-
- ///
- /// Returns a list of kippt lists.
- ///
- ///
- ///
- /// Results are paginated.
- /// The default number of returned clips is 20.
- /// Pagination information are stored in the Meta property of class.
- ///
- public static KipptListCollection GetLists()
- {
- return KipptApi.ApiAction(ApiCommand.Lists, HttpMethod.Get);
- }
-
- ///
- /// Returns a specific number of kippt lists.
- ///
- ///
- /// Number of lists.
- public static KipptListCollection GetLists(int limit)
- {
- return GetLists(limit, 0);
- }
-
- ///
- /// Returns a range of kippt lists.
- ///
- ///
- /// End index.
- /// Start index.
- public static KipptListCollection GetLists(int limit, int offset)
- {
- Dictionary parameters = new Dictionary();
-
- parameters.Add("limit", limit);
-
- if (offset > 0) parameters.Add("offset", offset);
-
- return KipptApi.ApiAction(ApiCommand.Lists, HttpMethod.Get, parameters);
- }
-
- ///
- /// Returns a kippt list by its id.
- ///
- ///
- /// List id.
- public static KipptList GetList(int id)
- {
- return KipptApi.ApiAction(ApiCommand.List, HttpMethod.Get, id);
- }
-
- #endregion Shared Methods
- }
+/*
+ Kippt.NET Library for consuming Kippt APIs.
+ Copyright (C) 2012 Haythem Tlili
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+namespace Kippt
+{
+ ///
+ /// Lists are used to organize and categorize clips. Clips will have a list associated to them.
+ /// Every user has two lists predefined, inbox and read-later, which can't be deleted.
+ ///
+ [DataContract]
+ public class KipptList : KipptClient
+ {
+ #region Properties
+
+ ///
+ /// Gets list id.
+ ///
+ [DataMember(Name = "id")]
+ public int Id { get; set; }
+
+ ///
+ /// Gets or sets list title.
+ ///
+ [DataMember(Name = "title")]
+ public string Title { get; set; }
+
+ ///
+ /// Gets list slug.
+ ///
+ [DataMember(Name = "slug")]
+ public string Slug { get; set; }
+
+ [DataMember(Name = "created")]
+ public int dateCreated;
+ ///
+ /// Gets the creation date of a list.
+ ///
+ public DateTime DateCreated
+ {
+ get { return Utils.FromUnixTime(dateCreated); }
+ }
+
+ [DataMember(Name = "updated")]
+ public int dateUpdated;
+ ///
+ /// Gets the update date of a list.
+ ///
+ public DateTime DateUpdated
+ {
+ get { return Utils.FromUnixTime(dateUpdated); }
+ }
+
+ ///
+ /// Gets the permalink of a list.
+ ///
+ [DataMember(Name = "resource_uri")]
+ public string ResourceUri { get; set; }
+
+ ///
+ /// Gets the rss uri of a list.
+ ///
+ [DataMember(Name = "rss_url")]
+ public Uri Rss { get; set; }
+
+ #endregion Properties
+
+ #region Public Methods
+
+ ///
+ /// Returns a list of clips associated to the list instance.
+ ///
+ ///
+ ///
+ /// Results are paginated.
+ /// The default number of returned clips is 20.
+ /// Pagination information are stored in the Meta property of class.
+ ///
+ public KipptClipCollection GetClips()
+ {
+ return KipptClip.GetClipsByList(this.Id, 100000);
+ }
+
+ ///
+ /// Creates a kippt list.
+ ///
+ public void Create()
+ {
+ KipptApi.ApiAction(ApiCommand.Lists, HttpMethod.Post, JsonSerializer.Serialize(this));
+ }
+
+ ///
+ /// Updates a kippt list.
+ ///
+ public void Update()
+ {
+ KipptApi.ApiAction(ApiCommand.List, HttpMethod.Put, JsonSerializer.Serialize(this), this.Id);
+ }
+
+ ///
+ /// Deletes a kippt list.
+ ///
+ public void Delete()
+ {
+ KipptApi.ApiAction(ApiCommand.List, HttpMethod.Delete, this.Id);
+ }
+
+ #endregion Public Methods
+
+ #region Shared Methods
+
+ ///
+ /// Returns a list of kippt lists.
+ ///
+ ///
+ ///
+ /// Results are paginated.
+ /// The default number of returned clips is 20.
+ /// Pagination information are stored in the Meta property of class.
+ ///
+ public static KipptListCollection GetLists()
+ {
+ return KipptApi.ApiAction(ApiCommand.Lists, HttpMethod.Get);
+ }
+
+ ///
+ /// Returns a specific number of kippt lists.
+ ///
+ ///
+ /// Number of lists.
+ public static KipptListCollection GetLists(int limit)
+ {
+ return GetLists(limit, 0);
+ }
+
+ ///
+ /// Returns a range of kippt lists.
+ ///
+ ///
+ /// End index.
+ /// Start index.
+ public static KipptListCollection GetLists(int limit, int offset)
+ {
+ Dictionary parameters = new Dictionary();
+
+ parameters.Add("limit", limit);
+
+ if (offset > 0) parameters.Add("offset", offset);
+
+ return KipptApi.ApiAction(ApiCommand.Lists, HttpMethod.Get, parameters);
+ }
+
+ ///
+ /// Returns a kippt list by its id.
+ ///
+ ///
+ /// List id.
+ public static KipptList GetList(int id)
+ {
+ return KipptApi.ApiAction(ApiCommand.List, HttpMethod.Get, id);
+ }
+
+ #endregion Shared Methods
+ }
}
\ No newline at end of file
diff --git a/Source/Kippt/Utils.cs b/Source/Kippt/Utils.cs
index f6be287..9f743bc 100644
--- a/Source/Kippt/Utils.cs
+++ b/Source/Kippt/Utils.cs
@@ -1,61 +1,87 @@
-/*
- Kippt.NET Library for consuming Kippt APIs.
- Copyright (C) 2012 Haythem Tlili
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-using System;
-using System.Linq;
-using System.Text;
-using System.Collections.Generic;
-
-namespace Kippt
-{
- ///
- /// Common helpers.
- ///
- class Utils
- {
- #region Uri
-
- ///
- /// Returns an Uri after replacement of the format item with the corresponding string representation.
- ///
- ///
- /// Input Uri.
- /// Format items.
- public static Uri FormatToUri(Uri uri, params object[] keys)
- {
- return new Uri(string.Format(uri.ToString(), keys));
- }
-
- ///
- /// Adds query strings to a given uri.
- ///
- ///
- /// Input uri.
- /// Dictionnary of parameters to add.
- public static Uri AddParametersToUri(Uri baseUri, Dictionary parameters)
- {
- StringBuilder sb = new StringBuilder(baseUri.ToString());
-
- sb.Append("?");
- sb.Append(string.Join("&", parameters.Select(p => string.Format("{0}={1}", p.Key, p.Value.ToString()))));
-
- return new Uri(sb.ToString());
- }
-
- #endregion Uri
- }
-}
+/*
+ Kippt.NET Library for consuming Kippt APIs.
+ Copyright (C) 2012 Haythem Tlili
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+using System;
+using System.Linq;
+using System.Text;
+using System.Collections.Generic;
+
+namespace Kippt
+{
+ ///
+ /// Common helpers.
+ ///
+ class Utils
+ {
+ #region Uri
+
+ ///
+ /// Returns an Uri after replacement of the format item with the corresponding string representation.
+ ///
+ ///
+ /// Input Uri.
+ /// Format items.
+ public static Uri FormatToUri(Uri uri, params object[] keys)
+ {
+ return new Uri(string.Format(uri.ToString(), keys));
+ }
+
+ ///
+ /// Adds query strings to a given uri.
+ ///
+ ///
+ /// Input uri.
+ /// Dictionnary of parameters to add.
+ public static Uri AddParametersToUri(Uri baseUri, Dictionary parameters)
+ {
+ StringBuilder sb = new StringBuilder(baseUri.ToString());
+
+ sb.Append("?");
+ sb.Append(string.Join("&", parameters.Select(p => string.Format("{0}={1}", p.Key, p.Value.ToString()))));
+
+ return new Uri(sb.ToString());
+ }
+
+ #endregion Uri
+
+ #region Date
+
+ ///
+ /// Converts a date to Unix time format.
+ ///
+ ///
+ ///
+ ///
+ /// Date to convert.
+ public static int ToUnixTime(DateTime date)
+ {
+ return (date - new DateTime(1970, 1, 1, 0, 0, 0)).Milliseconds;
+ }
+
+ ///
+ /// Converts unix time format to a date.
+ ///
+ ///
+ /// Unix time date.
+ public static DateTime FromUnixTime(int date)
+ {
+ return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddMilliseconds(date * 1000L);
+ }
+
+ #endregion Date
+ }
+}
\ No newline at end of file