Exemplo n.º 1
0
        public HTTPRequest GetRequest()
        {
            HTTPRequest request = new HTTPRequest(_baseRequest);
            CultureInfo culture = new CultureInfo(_data.SearchLang);

            if (_data.DayNames != null)
            {
                request.ReplaceTag("[DAY_NAME]", _data.DayNames[_dayOffset]);
            }

            if (_data.BaseDate != null)
            {
                DateTime basedt = DateTime.Parse(_data.BaseDate);
                request.ReplaceTag("[DAYS_SINCE]", _requestTime.DaysSince(basedt).ToString());
            }

            request.ReplaceTag("[ID]", _data.ChannelId);

            request.ReplaceTag("[DAY_OFFSET]", (_dayOffset + _data.OffsetStart).ToString());
            request.ReplaceTag("[EPOCH_TIME]", _requestTime.ToEpochTime().ToString());
            request.ReplaceTag("[EPOCH_DATE]", _requestTime.ToEpochDate().ToString());
            request.ReplaceTag("[DAYOFYEAR]", _requestTime.DateTime.DayOfYear.ToString());
            request.ReplaceTag("[YYYY]", _requestTime.Year.ToString());
            request.ReplaceTag("[MM]", String.Format("{0:00}", _requestTime.Month));
            request.ReplaceTag("[_M]", _requestTime.Month.ToString());
            request.ReplaceTag("[MONTH]", _requestTime.DateTime.ToString("MMMM", culture));
            request.ReplaceTag("[DD]", String.Format("{0:00}", _requestTime.Day));
            request.ReplaceTag("[_D]", _requestTime.Day.ToString());

            // this fix is needed for countries where the first day (0) is Sunday (not Monday)
            // thoose grabbers should include OffsetStart="1" in the Search tag.
            int dayNum = (int)_requestTime.DateTime.DayOfWeek + _data.OffsetStart;

            if (dayNum < 0)
            {
                dayNum += 7;
            }
            if (dayNum > 6)
            {
                dayNum = dayNum % 7;
            }
            request.ReplaceTag("[DAY_OF_WEEK]", dayNum.ToString());

            // check for script defined weekdayname and use it if found
            if (_data.WeekDayNames != null && dayNum < _data.WeekDayNames.Length && _data.WeekDayNames[dayNum] != String.Empty)
            {
                request.ReplaceTag("[WEEKDAY]", _data.WeekDayNames[dayNum]);
            }
            else
            {
                request.ReplaceTag("[WEEKDAY]", _requestTime.DateTime.ToString(_data.WeekDay, culture));
            }

            request.ReplaceTag("[LIST_OFFSET]", ((_offset * _data.MaxListingCount) + _data.ListStart).ToString());
            request.ReplaceTag("[PAGE_OFFSET]", (_offset + _data.PageStart).ToString());

            return(request);
        }
Exemplo n.º 2
0
        public void ToLocalTime()
        {
            WorldDateTime wdt = new WorldDateTime(DateTime.Now);

            DateTime dtEpochStartTime = Convert.ToDateTime("1/1/1970 8:00:00 AM");

            Assert.IsTrue(wdt.DaysSince(dtEpochStartTime) == wdt.ToEpochDate());
            Assert.IsTrue(wdt.SecondsSince(dtEpochStartTime) == wdt.ToEpochTime());
        }