Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Oct 21, 2010 @ 12:13
    Jeroen Breuer
    0

    Wrong twitter time

    Hello,

    This topic isn't really Umbraco related, but I'm using the Twitter for Umbraco package (which is great!) and the time from all tweets is wrong. It's 2 hours behind. The created_at date says 09:00, but it was created on 11:00. Is it because of a different time zone?

    Also is there an easy way to show "3 hours ago" as the time instead of the create date?

    Jeroen

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Oct 21, 2010 @ 16:03
    Warren Buckley
    0

    Hi Jeroen,
    I would check the XML feed directly from twitter to see what times is being returned.
    Unfortunately my package cant do anything to help with that.

    I am not sure if there is a timezone setting in your twitter account on twitter.com this could affect these time/date values if not then you will need to add some logic into your XSLT to either add or substract from the XML date/time to suit your needs.

    Thanks,
    Warren :)

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Oct 21, 2010 @ 16:08
    Jeroen Breuer
    0

    Hi Warren,

    I've check the XML feed directly from twitter and there the time is also wrong. For now I just add 2 hours to the time and everything is fine, but that's not the best solution off course.

    Jeroen

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Oct 21, 2010 @ 16:31
    Warren Buckley
    0

    Jeroen,
    I know its not the best solution. However I have no control over the XML feed ;)

    Warren

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Oct 21, 2010 @ 17:02
    Morten Bock
    0

    As far as I can tell, the date in the feed looks like this:

    "Wed Aug 25 19:40:45 +0000 2010"

    Is that correct? If so, then the "+0000" indicates that the time is in UTC, meaning that it has a 0 offset. So it makes perfect sense, that the date might be a couple of hours off the time you expect because of timezones/daylight savings.

    A solution could be that the CWS.Twitter:FormatTwitterDate(created_at) method parses the date as being UTC, and the converts it into local time (meaning the servers time setting). That would work for 90% of people. Alternatively, supply an overload allowing to pass in a timezone that the time should be converted to.

    Hope that makes sense :-)

     

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Oct 21, 2010 @ 17:25
    Warren Buckley
    0

    Morten & Jeroen,
    The package is open source and is open to contributors if you want to help fix or improve twitter for umbraco.

    I just sturggle to find time to keep up to date with all my packages.
    Warren :)

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Oct 21, 2010 @ 18:15
    Morten Bock
    0

    I can fix the date method if you want? Just need codeplex access :)

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Oct 21, 2010 @ 19:40
    Morten Bock
    0

    Just changed the method a bit to convert to local time. Was looking at making an overload for changing timezones, but that got pretty messy very quick, when starting to think about daylight savings and all... So for now:

    public static string FormatTwitterDate(string twitterDate)
    {
        DateTime parsedDate;
        if (DateTime.TryParseExact(twitterDate, "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out parsedDate))
        {
            return parsedDate.ToLocalTime().ToString("s");
        }
        return "1900-01-01T00:00:00";
    }

    Should fit most needs.

    As an instant fix, you can just add this method as inline C# in the xslt until there is an updated package...

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Oct 21, 2010 @ 20:34
    Warren Buckley
    0

    Hi Morten do you want to become a contributor and work on obviously adding this and maybe any other ideas or improvements you may have?

    Cheers,
    Warren :)

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Oct 21, 2010 @ 22:51
    Morten Bock
    0

    Sure thing. You can add me on codeplex: "mortenbock".

    Will check in the changes, and then we can coordinate how the packaging works :)

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Oct 22, 2010 @ 10:04
    Warren Buckley
    0

    Added you on Codeplex, if you add yourself or send request to be a contributor on our.umbraco.org project page then I can add you there as well.

    Cheers,
    Warren :)

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Oct 22, 2010 @ 10:05
    Warren Buckley
    0

    Added you on Codeplex, if you add yourself or send request to be a contributor on our.umbraco.org project page then I can add you there as well.

    Cheers,
    Warren :)

  • Lars Skjoldby 11 posts 29 karma points
    Feb 24, 2012 @ 15:17
    Lars Skjoldby
    0

    @Morten. Can you tell me what I need to do to inline your quick fix in the xslt? How should the exact code look?

Please Sign in or register to post replies

Write your reply to:

Draft