Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6363203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:00:29+00:00 2026-05-25T00:00:29+00:00

I am currently pulling start times from an XML file and using a date

  • 0

I am currently pulling start times from an XML file and using a date checking method to filter and then display in a Listbox.Itemsource.

Currently the start times are in “yyyyMMddHHmmss zzz” format in my XML file and my DateChecking method is also the same format for comparison to work.

What I would like to do is to convert the format from “yyyyMMddHHmmss zzz” to Long format “Wednesday 19th June 12:00 PM and have this display in the listbox.

The Code #######################################################

namespace TV_Guide_Version2
{
    public partial class TV2 : PhoneApplicationPage
    {
        public TV2()
        {
            InitializeComponent();
        }
        private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
        {
            WebClient c = new WebClient();
            c.DownloadStringCompleted += new DownloadStringCompletedEventHandler(c_DownloadStringCompleted);
            c.DownloadStringAsync(new Uri("http://www.Domain.com/XMLSrouce.xml?"));

        }

        bool MyDateCheckingMethod(string dateString)
        {
            DateTime now = DateTime.Now.Date.Add(DateTime.Now.TimeOfDay);
            DateTime otherDate = DateTime.ParseExact(dateString, "yyyyMMddHHmmss K", null);

            return (now.AddHours(-2) <= otherDate && otherDate <= now.AddHours(24));
        }


        void c_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
                return;


            var r = XDocument.Parse(e.Result);



            listBox1.ItemsSource = from tv in r.Root.Descendants("programme")
                                   where tv.Attribute("channel").Value == "1201"
                                   where MyDateCheckingMethod(tv.Attribute("start").Value)
                                   let channelE1 = tv.Attribute("channel")
                                   let startE1 = tv.Attribute("start")
                                   let nameEl = tv.Element("title")
                                   orderby tv.Attribute("start").Value ascending
                                   let urlEl = tv.Element("desc")


                                   select new TV1guide



                                   {
                                       DisplayName = nameEl == null ? null : nameEl.Value,
                                       ChannelName = channelE1 == null ? null : channelE1.Value,
                                       ChannelURL = urlEl == null ? null : urlEl.Value,
                                       StartTime = startE1 == null ? (DateTime?)null : DateTime.ParseExact(startE1.Value, "yyyyMMddHHmmss zzz", DateTimeFormatInfo.CurrentInfo, DateTimeStyles.AssumeLocal),



                                   };



        }

        public class TV1guide
        {
            public string DisplayName { get; set; }
            public string ChannelURL { get; set; }
            public string ImageSource { get; set; }
            public DateTime? StartTime { get; set; }
            public DateTime? EndTime { get; set; }
            public string ChannelName { get; set; }

        }




    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:00:29+00:00Added an answer on May 25, 2026 at 12:00 am

    This appears to do the trick:

    var input = "20110901070000 +1100";
    var dateTime = DateTimeOffset.ParseExact(input, "yyyyMMddHHmmss zzz", DateTimeFormatInfo.CurrentInfo);
    var longFormat = dateTime.ToString("D");
    

    Using DateTimeOffset makes it easier when working with times in different timezones.

    EDIT:

    I think there are two problems we are trying to solve here, if I am not mistaken. Let’s break it down:

    1. We want to parse a Date/Time for purposes of displaying cleanly.
    2. We want to filter by that Date/Time to display only certain records.

    I think the first bit is to make sure we get all of the information into a correct data type. Something like this:

        var data = 
            from tv in r.Root.Descendants("programme")
            where tv.Attribute("channel").Value == "1201"
            let channelE1 = tv.Attribute("channel")
            let startE1 = tv.Attribute("start")
            let nameEl = tv.Element("title")
            orderby tv.Attribute("start").Value ascending
            let urlEl = tv.Element("desc")
            let guide = new TV1guide
            {
                DisplayName = nameEl == null ? null : nameEl.Value,
                ChannelName = channelE1 == null ? null : channelE1.Value,
                ChannelURL = urlEl == null ? null : urlEl.Value,
                StartTime = startE1 == null ? (DateTimeOffset?)null : ParseDate(startE1.Value),
            }
            where DateTimeOffset.Now.AddHours(-2) <= guide.StartTime && guide.StartTime <= DateTimeOffset.Now.AddDays(1)
            select guide;
    }
    
    private static DateTimeOffset ParseDate(string value)
    {
        return  DateTimeOffset.ParseExact(value, "yyyyMMddHHmmss zzz", DateTimeFormatInfo.CurrentInfo);
    }
    

    Now, if you wanted, you could introduce another property on TV1guide that displays it the way you’d like:

    public string StartTimeDisplay {get { return StartTime.HasValue ? StartTime.Value.ToString("D") : ""; }}
    

    Or if you feel that it is too odd putting it there, you can place it whereever you’d like. THe point being now that it has been parsed into the TV1guide, you can display it however you need to when the time comes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I'm using <pre><code> code here </code><pre> to display code. I'm pulling this information
I have this find condition pulling from my model that currently looks like this.
I am pulling information from a binary file in C and one of my
We're currently pulling jQuery and jQueryUI (and jQueryUI CSS) libraries from the google CDN.
Currently, I don't really have a good method of debugging JavaScript in Internet Explorer and
Currently I'm doing some unit tests which are executed from bash. Unit tests are
Currently, I am developing a product that does fairly intensive calculations using MS SQL
I am currently pulling three form field inputs off the request object. The day,
I'm looking to randomize the output from a plist file. I've read about arc4random(),
In an embedded application programmed on C on ARM7 (with portability requirements), currently using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.