public void ShouldReturnCorrectUnixTime() { var dateTime = new DateTime(2012, 1, 28, 18, 14, 33, DateTimeKind.Utc); var result = DateTimeConvertor.ToUnixTime(dateTime); Assert.Equal(1327774473, result); }
public void ConvertToAndFromUnixTime_Double() { var unixTimeInDouble = 1213513200; var fbUnix = DateTimeConvertor.FromUnixTime(unixTimeInDouble); var unixTime = DateTimeConvertor.ToUnixTime(fbUnix); Assert.Equal(unixTimeInDouble, unixTime); }
public void ConvertToAndFromUnixTime_String() { var unixTimeInString = "1213513200"; var fbUnix = DateTimeConvertor.FromUnixTime(unixTimeInString); var unixTime = DateTimeConvertor.ToUnixTime(fbUnix); Assert.Equal(unixTimeInString, unixTime.ToString()); }
public void ReturnsUnixTimeEquivalent() { DateTimeOffset dateTime = new DateTimeOffset(2010, 9, 16, 0, 0, 0, TimeSpan.FromHours(-7)); var expected = 1284620400; var actual = DateTimeConvertor.ToUnixTime(dateTime); Assert.Equal(expected, actual); }
public void ShouldNotContainDecimal() { var dateTime = new DateTime(2012, 1, 28, 18, 14, 33, 18, DateTimeKind.Utc); var result = DateTimeConvertor.ToUnixTime(dateTime); Assert.DoesNotContain(".", result.ToString(CultureInfo.InvariantCulture)); Assert.Equal("1327774473", result.ToString(CultureInfo.InvariantCulture)); }
private void scheduleLink(string pageToken, string pageid, string link, DateTime schedule) { FacebookClient fbclient = new FacebookClient(pageToken); string dts = DateTimeConvertor.ToUnixTime(schedule).ToString(); dynamic parms = new ExpandoObject(); parms.link = link; parms.published = false; parms.scheduled_publish_time = dts; fbclient.Post(pageid + "/feed", parms); }
private string CreateScheduleStatusPost(Post post, bool isPublished, DateTime scheduleTime) { try { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("message", post.Message); if (!isPublished) { parameters.Add("published", "0"); parameters.Add("scheduled_publish_time", DateTimeConvertor.ToUnixTime(DateTime.Now.AddHours(1))); //parameters.Add("scheduled_publish_time", DateTimeConvertor.ToUnixTime(scheduleTime)); } return(postManager.CreatePost(parameters)); } catch (Exception ex) { throw ex; } }
private void ScheduleVideo(string pageToken, string pageid, string vidPath, DateTime schedDate, string description) { FacebookClient fbclient = new FacebookClient(pageToken); string dts = DateTimeConvertor.ToUnixTime(schedDate).ToString(); dynamic parameters = new ExpandoObject(); parameters.scheduled_publish_time = dts; parameters.published = false; if (description != null) { parameters.message = description; } parameters.source = new FacebookMediaObject { ContentType = "video/" + Path.GetExtension(vidPath), FileName = vidPath }.SetValue(File.ReadAllBytes(vidPath)); fbclient.Post(pageid + "/videos", parameters); }
private void _Build(DateTime dateTime) { sb.AppendFormat("'{0}' ", DateTimeConvertor.ToUnixTime(dateTime)); }