Copied to clipboard

Flag this post as spam?

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


  • Michael Nielsen 99 posts 619 karma points
    Jun 30, 2015 @ 13:51
    Michael Nielsen
    0

    StartDate and EndDate format in getEvent()

    Is start- and enddate required to be in a specific format?

    In a multi site solutions, events from the danish site is outputted, but not from the swedish.

    The only difference is that the date format is different because of different culture

    Danish 30-06-2014 00:00:00 30-06-2016 00:00:00

    Swedish 2014-06-30 00:00:00 2016-06-30 00:00:00

    I would like to test it by forcing in another format, by using

    DateTime.Parse("01-01-2015", new CultureInfo("da-DK", false));
    

    but to do that

    @using System.Globalization
    

    is required, and that causes another problem, described in this post

    https://our.umbraco.org/projects/website-utilities/ksumbraco7calendar/ksumbraco7calendar/67012-can-this-not-be-used-with-systemglobalization

    Any thoughts or workarounds are appreciated.

  • Ole Martin Bakke 108 posts 619 karma points
    Jun 30, 2015 @ 14:20
    Ole Martin Bakke
    0

    As long as it is a DateTime I don't think it matters. Are you adding events directly to Umbraco backend, or are users adding them from the frontend? How do you choose start- and end-date? Automatically or does the user choose anything? If there are som user input, then the issue probably is in the parsing of that.

  • Ole Martin Bakke 108 posts 619 karma points
    Jun 30, 2015 @ 14:21
    Ole Martin Bakke
    1

    It could help me if you provide your code.

  • Michael Nielsen 99 posts 619 karma points
    Jul 01, 2015 @ 09:51
    Michael Nielsen
    100

    Yep, you're right, DateFormat does not matter...

    The different languages use the same templates, so it's also the same partial that is used.

    The code in it was this

    @foreach(CalendarEvent ce in Calendar.getEvents(DateTime.Now.AddMonths(-12).Date, DateTime.Now.AddMonths(12).Date,"dates","Event",false)){
        @ce.content.Name 
    }
    

    This outputted the danish events, on both the danish and swedish site.

    But when when I changed it to (added CurrentPage as StartNode)

    @foreach(CalendarEvent ce in Calendar.getEvents(DateTime.Now.AddMonths(-12).Date, DateTime.Now.AddMonths(12).Date,"dates","Event",CurrentPage,false)){
        @ce.content.Name 
    }
    

    it solved it, now danish events are outputted on the danish site, and swedish events are outputted in the swedish site.

    So everything works, and thanks for a great package.

Please Sign in or register to post replies

Write your reply to:

Draft