/// <summary> /// Initializes an instance with the specified <paramref name="identifier"/>, <paramref name="limit"/>, /// <paramref name="until"/> and collection of <paramref name="fields"/>. /// </summary> /// <param name="identifier">The identifier (ID) of the page or user.</param> /// <param name="limit">The maximum amount of items to be returned per page.</param> /// <param name="until">The timestamp that points to the end of the range of time-based data.</param> /// <param name="fields">A collection of the fields that should be returned by the API.</param> public FacebookGetPostsOptions(string identifier, int limit, EssentialsTime until, FacebookFieldsCollection fields) : this() { Identifier = identifier; Limit = limit; Until = until; Fields = fields ?? new FacebookFieldsCollection(); }
/// <summary> /// Initializes a new instance based on the specified <paramref name="obj"/>. /// </summary> /// <param name="obj">The instance of <see cref="JObject"/> representing the event.</param> protected FacebookEvent(JObject obj) : base(obj) { Id = obj.GetString("id"); AttendingCount = obj.GetInt32("attending_count"); CanGuestsInvite = obj.GetBoolean("can_guests_invite"); Category = obj.GetEnum("category", FacebookEventCategory.Unspecified); Cover = obj.GetObject("cover", FacebookCoverPhoto.Parse); DeclinedCount = obj.GetInt32("declined_count"); Description = obj.GetString("description"); EndTime = obj.GetString("end_time", EssentialsTime.Parse); GuestListEnabled = obj.GetBoolean("guest_list_enabled"); InterestedCount = obj.GetInt32("interested_count"); IsCanceled = obj.GetBoolean("is_canceled"); IsPageOwned = obj.GetBoolean("is_page_owned"); IsViewerAdmin = obj.GetBoolean("is_viewer_admin"); MaybeCount = obj.GetInt32("maybe_count"); Name = obj.GetString("name"); NoreplyCount = obj.GetInt32("noreply_count"); Owner = obj.GetObject("owner", FacebookEventOwner.Parse); // parent_group"); Place = obj.GetObject("place", FacebookPlace.Parse); StartTime = obj.GetString("start_time", EssentialsTime.Parse); TicketUri = obj.GetString("ticket_uri"); Timezone = obj.GetString("timezone"); Type = obj.GetEnum("type", FacebookEventType.Unspecified); UpdatedTime = obj.GetString("updated_time", EssentialsTime.Parse); }
public void FromJsonDouble() { EssentialsTime time1 = new EssentialsTime(2019, 01, 20, 11, 22, 35, TimeSpan.Zero).AddMilliseconds(123); Sample sample1 = new Sample(time1); string source = new JObject { { "time1", 1547983355.00001 }, { "time2", 1547983355123.00001 }, { "time3", 1547983355.00001 }, { "time4", 1547983355123.00001 }, { "time5", 1547983355.00001 }, { "time6", 1547983355123.00001 }, { "time7", 1547983355.00001 }, { "time8", 1547983355123.00001 } }.ToString(); Sample sample2 = JsonUtils.ParseJsonObject <Sample>(source); Assert.AreEqual(WithSeconds(sample1.Time1), WithSeconds(sample2.Time1), "Time1"); Assert.AreEqual(WithMilliseconds(sample1.Time2), WithMilliseconds(sample2.Time2), "Time2"); Assert.AreEqual(WithSeconds(sample1.Time3), WithSeconds(sample2.Time3), "Time3"); Assert.AreEqual(WithMilliseconds(sample1.Time4), WithMilliseconds(sample2.Time4), "Time4"); Assert.AreEqual(WithSeconds(sample1.Time5), WithSeconds(sample2.Time5), "Time5"); Assert.AreEqual(WithMilliseconds(sample1.Time6), WithMilliseconds(sample2.Time6), "Time6"); Assert.AreEqual(WithSeconds(sample1.Time7), WithSeconds(sample2.Time7), "Time7"); Assert.AreEqual(WithMilliseconds(sample1.Time8), WithMilliseconds(sample2.Time8), "Time8"); }
public void FromSwatchInternetTime() { TimeZoneInfo utc = TimeZoneInfo.FindSystemTimeZoneById("UTC"); TimeZoneInfo romance = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time"); var r1 = EssentialsTime.FromSwatchInternetTime(2020, 8, 17, 315, utc); var r2 = EssentialsTime.FromSwatchInternetTime(2020, 8, 17, 315, romance); var r3 = EssentialsTime.FromSwatchInternetTime(new EssentialsDate(2020, 8, 17), 315, utc); var r4 = EssentialsTime.FromSwatchInternetTime(new EssentialsDate(2020, 8, 17), 315, romance); var r5 = EssentialsTime.FromSwatchInternetTime(2020, 11, 14, 619, utc); var r6 = EssentialsTime.FromSwatchInternetTime(2020, 11, 14, 619, romance); var r7 = EssentialsTime.FromSwatchInternetTime(new EssentialsDate(2020, 11, 14), 619, utc); var r8 = EssentialsTime.FromSwatchInternetTime(new EssentialsDate(2020, 11, 14), 619, romance); Assert.AreEqual("2020-08-17T06:33:36.000Z", r1.Iso8601, "#1"); Assert.AreEqual("2020-08-17T08:33:36.000+02:00", r2.Iso8601, "#2"); Assert.AreEqual("2020-08-17T06:33:36.000Z", r3.Iso8601, "#1"); Assert.AreEqual("2020-08-17T08:33:36.000+02:00", r4.Iso8601, "#2"); Assert.AreEqual("2020-11-14T13:51:21.600Z", r5.Iso8601, "#5"); Assert.AreEqual("2020-11-14T14:51:21.600+01:00", r6.Iso8601, "#6"); Assert.AreEqual("2020-11-14T13:51:21.600Z", r7.Iso8601, "#7"); Assert.AreEqual("2020-11-14T14:51:21.600+01:00", r8.Iso8601, "#8"); }
public void GetSwatchInternetTime() { var t1 = EssentialsTime.FromUnixTimeSeconds(1605361960); var r1 = (int)SwatchUtils.ToDouble(t1); var t2 = new DateTime(2020, 11, 14, 13, 52, 40, DateTimeKind.Utc); var r2 = (int)SwatchUtils.ToDouble(t2); var t3 = new DateTimeOffset(2020, 11, 14, 14, 52, 40, TimeSpan.FromHours(1)); var r3 = (int)SwatchUtils.ToDouble(t3); var t4 = EssentialsTime.FromUnixTimeSeconds(1597646100); var r4 = (int)SwatchUtils.ToDouble(t4); var t5 = new DateTime(2020, 8, 17, 6, 35, 00, DateTimeKind.Utc); var r5 = (int)SwatchUtils.ToDouble(t5); var t6 = new DateTimeOffset(2020, 8, 17, 8, 35, 00, TimeSpan.FromHours(2)); var r6 = (int)SwatchUtils.ToDouble(t6); Assert.AreEqual(619, r1, "#1"); Assert.AreEqual(619, r2, "#2"); Assert.AreEqual(619, r3, "#3"); Assert.AreEqual(315, r4, "#1"); Assert.AreEqual(315, r5, "#2"); Assert.AreEqual(315, r6, "#3"); }
/// <summary> /// Initializes a new instance based on the specified <paramref name="identifier"/>, <paramref name="limit"/> /// and <paramref name="until"/>. /// </summary> /// <param name="identifier">The identifier (ID) of the page or user.</param> /// <param name="limit">The maximum amount of items to be returned per page.</param> /// <param name="until">The timestamp that points to the end of the range of time-based data.</param> public FacebookGetFeedOptions(string identifier, int limit, EssentialsTime until) { Identifier = identifier; Limit = limit; Until = until; Fields = new FacebookFieldsCollection(); }
public void GetWeekNumber() { EssentialsTime dec27 = new EssentialsTime(2021, 12, 27, 0, 0, 0, TimeSpan.Zero); EssentialsTime dec28 = new EssentialsTime(2021, 12, 28, 0, 0, 0, TimeSpan.Zero); EssentialsTime dec29 = new EssentialsTime(2021, 12, 29, 0, 0, 0, TimeSpan.Zero); EssentialsTime dec30 = new EssentialsTime(2021, 12, 30, 0, 0, 0, TimeSpan.Zero); EssentialsTime dec31 = new EssentialsTime(2021, 12, 31, 0, 0, 0, TimeSpan.Zero); EssentialsTime jan01 = new EssentialsTime(2022, 1, 1, 0, 0, 0, TimeSpan.Zero); EssentialsTime jan02 = new EssentialsTime(2022, 1, 2, 0, 0, 0, TimeSpan.Zero); EssentialsTime jan03 = new EssentialsTime(2022, 1, 3, 0, 0, 0, TimeSpan.Zero); EssentialsTime jan04 = new EssentialsTime(2022, 1, 4, 0, 0, 0, TimeSpan.Zero); EssentialsTime jan05 = new EssentialsTime(2022, 1, 5, 0, 0, 0, TimeSpan.Zero); EssentialsTime jan06 = new EssentialsTime(2022, 1, 6, 0, 0, 0, TimeSpan.Zero); // The week number is based on the year with most days of the week. The week with the days from December // 27th to Januar 2nd has five days in 2021 and only two days in 2020, so it becomes Week 52 of 2021. The // week from Januar 3rd to January 9th has all it's days in 2020, so it becomes Week 1 of 2020. Assert.AreEqual(52, dec27.WeekNumber, "December 27th"); Assert.AreEqual(52, dec28.WeekNumber, "December 28th"); Assert.AreEqual(52, dec29.WeekNumber, "December 29th"); Assert.AreEqual(52, dec30.WeekNumber, "December 30th"); Assert.AreEqual(52, dec31.WeekNumber, "December 31st"); Assert.AreEqual(52, jan01.WeekNumber, "January 1st"); Assert.AreEqual(52, jan02.WeekNumber, "January 2nd"); Assert.AreEqual(1, jan03.WeekNumber, "January 3rd"); Assert.AreEqual(1, jan04.WeekNumber, "January 4th"); Assert.AreEqual(1, jan05.WeekNumber, "January 5th"); Assert.AreEqual(1, jan06.WeekNumber, "January 6th"); }
/// <summary> /// Returns the specified <paramref name="timestamp"/> as <strong>Swatch Internet Time</strong>. /// </summary> /// <param name="timestamp">An instance of <see cref="EssentialsTime"/> representing the timestamp.</param> /// <returns>A <see cref="double"/> reprenting the <strong>Swatch Internet Time</strong>.</returns> /// <see> /// <cref>https://en.wikipedia.org/wiki/Swatch_Internet_Time</cref> /// </see> public static double ToDouble(EssentialsTime timestamp) { if (timestamp == null) { throw new ArgumentNullException(nameof(timestamp)); } return(ToDouble(timestamp.DateTimeOffset)); }
public Sample(EssentialsTime time) { Time1 = Time2 = time.DateTimeOffset.DateTime; Time3 = Time4 = time.DateTimeOffset; Time5 = Time6 = new EssentialsDateTime(time.DateTimeOffset.DateTime); Time7 = Time8 = time; }
/// <summary> /// Gets a list of posts of the user or page with the specified <paramref name="identifier"/>. /// </summary> /// <param name="identifier">The identifier (ID or alias) of the user or page.</param> /// <param name="limit">The maximum amount of posts to be returned on each page.</param> /// <param name="until">A timestamp that points to the start of the range of time-based data.</param> /// <param name="fields">A collection of the fields that should be returned by the API.</param> /// <returns>An instance of <see cref="IHttpResponse"/> representing the raw response.</returns> public IHttpResponse GetPosts(string identifier, int limit, EssentialsTime until, FacebookFieldsCollection fields) { if (string.IsNullOrWhiteSpace(identifier)) { throw new ArgumentNullException(nameof(identifier), "A Facebook identifier (ID or alias) must be specified."); } return(GetPosts(new FacebookGetPostsOptions(identifier, limit, until, fields))); }
public void Add() { TimeZoneInfo utc = TimeZoneInfo.FindSystemTimeZoneById("UTC"); EssentialsTime value = new EssentialsTime(2022, 4, 25, 7, 55, 0, utc); EssentialsTime result = value.Add(TimeSpan.FromMinutes(5)); Assert.AreEqual(value.TimeZone, result.TimeZone); }
public void ConstructorDateTimeAndTimeZoneInfo4() { // Notice: this test is likely fail if the local time zone isn't Romance Standard Time DateTime input = new DateTime(2020, 9, 27, 14, 17, 21, DateTimeKind.Local); EssentialsTime result = new EssentialsTime(input, TimeZoneInfo.Utc); Assert.AreEqual("2020-09-27 12:17:21:000 +00:00", result.ToString(Format)); }
public void ConstructorDateTimeAndTimeZoneInfo2() { TimeZoneInfo romance = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time"); DateTime input = new DateTime(2020, 9, 27, 12, 17, 21, DateTimeKind.Utc); EssentialsTime result = new EssentialsTime(input, romance); Assert.AreEqual("2020-09-27 14:17:21:000 +02:00", result.ToString(Format)); }
public void ConstructorDateTimeAndTimeZoneInfo1() { TimeZoneInfo utc = TimeZoneInfo.FindSystemTimeZoneById("UTC"); DateTime input = new DateTime(2020, 9, 27, 12, 17, 21, DateTimeKind.Utc); EssentialsTime result = new EssentialsTime(input, utc); Assert.AreEqual("2020-09-27 12:17:21:000 +00:00", result.ToString(Format)); }
public void IsYesterday() { EssentialsTime yesterday = EssentialsTime.Today.AddDays(-1); EssentialsTime today = EssentialsTime.Today; EssentialsTime tomorrow = EssentialsTime.Today.AddDays(+1); Assert.AreEqual(true, yesterday.IsYesterday, "#yesterday"); Assert.AreEqual(false, today.IsYesterday, "#today"); Assert.AreEqual(false, tomorrow.IsYesterday, "#tomorrow"); }
public void GetDaysInMonth() { // 2020 was a leap year, 2021 isn't EssentialsTime y2020 = new EssentialsTime(2020, 2, 26, 0, 0, 0, TimeSpan.Zero); EssentialsTime y2021 = new EssentialsTime(2021, 2, 26, 0, 0, 0, TimeSpan.Zero); Assert.AreEqual(29, y2020.DaysInMonth); Assert.AreEqual(28, y2021.DaysInMonth); }
public void IsLeapYear() { // 2020 was a leap year, 2021 isn't EssentialsTime y2020 = new EssentialsTime(2020, 9, 27, 0, 0, 0, TimeSpan.Zero); EssentialsTime y2021 = new EssentialsTime(2021, 9, 27, 0, 0, 0, TimeSpan.Zero); Assert.IsTrue(y2020.IsLeapYear); Assert.IsFalse(y2021.IsLeapYear); }
public void AddTicks() { TimeZoneInfo utc = TimeZoneInfo.FindSystemTimeZoneById("UTC"); EssentialsTime value = new EssentialsTime(2022, 4, 25, 7, 55, 0, utc); EssentialsTime result = value.AddTicks(1); Assert.AreEqual(value.TimeZone, result.TimeZone); }
public void YearAndDay() { EssentialsTime a = new EssentialsTime(2019, 1, 1, 0, 0, 0, TimeSpan.Zero); EssentialsTime b = new EssentialsTime(2019, 10, 20, 0, 0, 0, TimeSpan.Zero); EssentialsTime c = new EssentialsTime(2019, 12, 31, 0, 0, 0, TimeSpan.Zero); Assert.AreEqual(2019001, a.YearAndDay); Assert.AreEqual(2019293, b.YearAndDay); Assert.AreEqual(2019365, c.YearAndDay); }
/// <summary> /// Parses the Unix timestamp at <paramref name="path"/>. /// /// In some cases, the Graph APi may return <c>0</c> indicating no value - if this is the case, this method will return <c>null</c> instead of <see cref="EssentialsTime.Zero"/>. /// </summary> /// <param name="obj">The parent object.</param> /// <param name="path">A <see cref="string"/> that contains a JPath expression.</param> /// <returns></returns> protected EssentialsTime ParseUnixTimestamp(JObject obj, string path) { if (obj.HasValue(path) == false) { return(null); } int value = obj.GetInt32(path); return(value > 0 ? EssentialsTime.FromUnixTimestamp(value) : null); }
public void ConstructorDateTimeAndTimeZoneInfo3() { // Convert to Eastern European Time TimeZoneInfo eet = TimeZoneInfo.FindSystemTimeZoneById("E. Europe Standard Time"); DateTime input = new DateTime(2020, 9, 27, 12, 17, 21, DateTimeKind.Utc); EssentialsTime result = new EssentialsTime(input, eet); Assert.AreEqual("2020-09-27 15:17:21:000 +03:00", result.ToString(Format)); }
public void EssentialsTime() { DateTime t = new DateTime(2019, 9, 14); EssentialsTime a = new EssentialsTime(2020, 9, 13, TimeSpan.Zero); EssentialsTime b = new EssentialsTime(2020, 9, 14, TimeSpan.Zero); EssentialsTime c = new EssentialsTime(2020, 9, 15, TimeSpan.Zero); Assert.AreEqual(0, TimeUtils.GetAge(t, a)); Assert.AreEqual(1, TimeUtils.GetAge(t, b)); Assert.AreEqual(1, TimeUtils.GetAge(t, c)); }
public void DateTime() { EssentialsTime t = new EssentialsTime(2019, 9, 14, TimeSpan.Zero); DateTime a = new DateTime(2020, 9, 13, 0, 0, 0, DateTimeKind.Utc); DateTime b = new DateTime(2020, 9, 14, 0, 0, 0, DateTimeKind.Utc); DateTime c = new DateTime(2020, 9, 15, 0, 0, 0, DateTimeKind.Utc); Assert.AreEqual(0, TimeUtils.GetAge(t, a)); Assert.AreEqual(1, TimeUtils.GetAge(t, b)); Assert.AreEqual(1, TimeUtils.GetAge(t, c)); }
public void DateTimeOffset() { EssentialsTime t = new EssentialsTime(2019, 9, 14, TimeSpan.Zero); DateTimeOffset a = new DateTimeOffset(2020, 9, 13, 0, 0, 0, TimeSpan.Zero); DateTimeOffset b = new DateTimeOffset(2020, 9, 14, 0, 0, 0, TimeSpan.Zero); DateTimeOffset c = new DateTimeOffset(2020, 9, 15, 0, 0, 0, TimeSpan.Zero); Assert.AreEqual(0, TimeUtils.GetAge(t, a)); Assert.AreEqual(1, TimeUtils.GetAge(t, b)); Assert.AreEqual(1, TimeUtils.GetAge(t, c)); }
public void GetEndOfDay() { TimeZoneInfo utc = TimeZoneInfo.FindSystemTimeZoneById("UTC"); TimeZoneInfo romance = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time"); var samples = new[] { new GetOfDaySample("2019-03-18 23:59:59:999 +00:00", "2019-03-18 12:00:00:000 +00:00", null), new GetOfDaySample("2019-03-23 23:59:59:999 +00:00", "2019-03-23 12:00:00:000 +00:00", null), new GetOfDaySample("2019-03-26 23:59:59:999 +00:00", "2019-03-26 12:00:00:000 +00:00", null), new GetOfDaySample("2019-03-18 23:59:59:999 +00:00", "2019-03-18 12:00:00:000 +00:00", utc), new GetOfDaySample("2019-03-23 23:59:59:999 +00:00", "2019-03-23 12:00:00:000 +00:00", utc), new GetOfDaySample("2019-03-26 23:59:59:999 +00:00", "2019-03-26 12:00:00:000 +00:00", utc), new GetOfDaySample("2019-03-23 23:59:59:999 +01:00", "2019-03-23 12:00:00:000 +01:00", romance), new GetOfDaySample("2019-03-24 23:59:59:999 +01:00", "2019-03-24 12:00:00:000 +01:00", romance), new GetOfDaySample("2019-03-25 23:59:59:999 +01:00", "2019-03-25 12:00:00:000 +01:00", romance), new GetOfDaySample("2019-03-26 23:59:59:999 +01:00", "2019-03-26 12:00:00:000 +01:00", romance), new GetOfDaySample("2019-03-27 23:59:59:999 +01:00", "2019-03-27 12:00:00:000 +01:00", romance), new GetOfDaySample("2019-03-28 23:59:59:999 +01:00", "2019-03-28 12:00:00:000 +01:00", romance), new GetOfDaySample("2019-03-29 23:59:59:999 +01:00", "2019-03-29 12:00:00:000 +01:00", romance), new GetOfDaySample("2019-03-30 23:59:59:999 +01:00", "2019-03-30 12:00:00:000 +01:00", romance), new GetOfDaySample("2019-03-31 23:59:59:999 +02:00", "2019-03-31 12:00:00:000 +02:00", romance), new GetOfDaySample("2019-04-01 23:59:59:999 +02:00", "2019-04-01 12:00:00:000 +02:00", romance), new GetOfDaySample("2019-04-02 23:59:59:999 +02:00", "2019-04-02 12:00:00:000 +02:00", romance), new GetOfDaySample("2019-10-23 23:59:59:999 +02:00", "2019-10-23 12:00:00:000 +02:00", romance), new GetOfDaySample("2019-10-25 23:59:59:999 +02:00", "2019-10-25 12:00:00:000 +02:00", romance), new GetOfDaySample("2019-10-27 23:59:59:999 +01:00", "2019-10-27 12:00:00:000 +01:00", romance), new GetOfDaySample("2019-10-29 23:59:59:999 +01:00", "2019-10-29 12:00:00:000 +01:00", romance) }; for (int i = 0; i < samples.Length; i++) { var s = samples[i]; DateTimeOffset result1 = TimeUtils.GetEndOfDay(s.Time, s.TimeZone); EssentialsTime result2 = new EssentialsTime(s.Time, s.TimeZone).GetEndOfDay(); EssentialsTime result3 = new EssentialsTime(s.Time, s.TimeZone).GetEndOfDay(s.TimeZone); Assert.AreEqual(s.Expected, result1.ToString(Format), $"Sample at index {i} failed test (DateTimeOffset)"); Assert.AreEqual(s.Expected, result2.ToString(Format), $"Sample at index {i} failed test (EssentialsTime)"); Assert.AreEqual(s.Expected, result2.ToString(Format), $"Sample at index {i} failed test (EssentialsTime)"); } }
public void TryParseFormat() { bool success1 = EssentialsTime.TryParse("2022-03-07T17:50:23.123+01:00", out EssentialsTime result1); string actual1 = result1.ToString(Iso8601Constants.DateTimeMilliseconds); bool success2 = EssentialsTime.TryParse("Monday, 07 March 2022 17:50:23", out EssentialsTime result2); string actual2 = result2.ToString(Iso8601Constants.DateTimeMilliseconds); Assert.IsTrue(success1); Assert.AreEqual("2022-03-07T17:50:23.123+01:00", actual1); Assert.IsTrue(success2); Assert.AreEqual("2022-03-07T17:50:23.000+01:00", actual2); }
public void FromTicksLocal() { DateTime dt = new DateTime(2021, 1, 13, 22, 00, 00, DateTimeKind.Local); Assert.AreEqual(637461720000000000, dt.Ticks, "#1"); // We can't use a format with offset or time zone, as it may differ depending on the environment Assert.AreEqual("2021-01-13T22:00:00", dt.ToString("yyyy-MM-ddTHH:mm:ss"), "#2"); // Convert to EssentialsTime EssentialsTime time = EssentialsTime.FromTicks(dt.Ticks); Assert.AreEqual(637461720000000000, time.Ticks, "#3"); Assert.AreEqual("2021-01-13T22:00:00", time.ToString("yyyy-MM-ddTHH:mm:ss"), "#4"); }
/// <summary> /// Initializes a new instance based on the specified <paramref name="obj"/>. /// </summary> /// <param name="obj">An instance of <see cref="JObject"/> representing the project.</param> protected TogglWorkspace(JObject obj) : base(obj) { Id = obj.GetInt32("id"); Name = obj.GetString("name"); IsPremium = obj.GetBoolean("premium"); IsAdmin = obj.GetBoolean("admin"); // TODO: Add support for "default_hourly_rate" property // TODO: Add support for "default_currency" property // TODO: Add support for "only_admins_may_create_projects" property // TODO: Add support for "only_admins_see_billable_rates" property // TODO: Add support for "rounding" property // TODO: Add support for "rounding_minutes" property At = obj.GetString("at", EssentialsTime.FromIso8601); // TODO: Add support for "logo_url" property }
public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { if (!(inter is string str) || str.Length <= 0 || !int.TryParse(str, out int seconds)) { return(null); } // Find the selected time zone TimeZoneInfo timeZone = GetTimeZoneInfo(propertyType.DataType.Configuration as UnixTimestampConfiguration); // Convert to UNIX time from the specified seconds EssentialsTime timestamp = EssentialsTime.FromUnixTimestamp(seconds).ToTimeZone(timeZone); return(timestamp); }
/// <summary> /// Gets a list of time entries of the authenticated user. /// </summary> /// <param name="startDate">Only time entries after this date are returned.</param> /// <param name="endDate">Only time entries before this date are returned.</param> /// <returns>An instance of <see cref="IHttpResponse"/> representing the raw response.</returns> /// <see> /// <cref>https://github.com/toggl/toggl_api_docs/blob/master/chapters/time_entries.md#get-time-entries-started-in-a-specific-time-range</cref> /// </see> public IHttpResponse GetEntries(EssentialsTime startDate, EssentialsTime endDate) { if (startDate == null) { throw new ArgumentNullException(nameof(startDate)); } if (endDate == null) { throw new ArgumentNullException(nameof(endDate)); } return(Client.Get($"https://{TogglConstants.Track.HostName}/api/v8/time_entries", new HttpQueryString { { "start_date", startDate.ToString(Iso8601Constants.DateTimeFormat) }, { "end_date", endDate.ToString(Iso8601Constants.DateTimeFormat) } })); }