public void ShouldReturnCorrectUnixTime()
                {
                    var dateTime = new DateTime(2012, 1, 28, 18, 14, 33, DateTimeKind.Utc);

                    var result = DateTimeConvertor.ToUnixTime(dateTime);

                    Assert.Equal(1327774473, result);
                }
예제 #2
0
        public void ConvertToAndFromUnixTime_Double()
        {
            var unixTimeInDouble = 1213513200;

            var fbUnix   = DateTimeConvertor.FromUnixTime(unixTimeInDouble);
            var unixTime = DateTimeConvertor.ToUnixTime(fbUnix);

            Assert.Equal(unixTimeInDouble, unixTime);
        }
예제 #3
0
        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));
            }
예제 #6
0
        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);
        }
예제 #7
0
 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;
     }
 }
예제 #8
0
        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);
        }
예제 #9
0
 private void _Build(DateTime dateTime)
 {
     sb.AppendFormat("'{0}' ", DateTimeConvertor.ToUnixTime(dateTime));
 }