MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Calendar showing 12h time format instead of 24h

    Scheduled Pinned Locked Moved Troubleshooting
    2 Posts 1 Posters 1.0k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • lavolp3L Offline
      lavolp3 Module Developer
      last edited by

      In my calendar module, all entries in the range two days from now are shown with “tomorrow/day after tomorrow at XX:00”, but the time is shown with 12h time format, although in MagicMirror config timeFormat is set to 24.

      I presume the reason is a function in calendar.js: in case the day of the event is < currentdate - 2 the event is derived from moment.calendar()

      if (event.startDate - now < 2 * oneDay) {
      	// This event is within the next 48 hours (2 days)
      	if (event.startDate - now < this.config.getRelative * oneHour) {
      	        // If event is within 6 hour, display 'in xxx' time format or moment.fromNow()
      		timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
      	} else {
      	        // Otherwise just say 'Today/Tomorrow at such-n-such time'
      		timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").calendar());
      	}
      

      0_1541361649708_17412b76-328a-4c7f-bfb9-0fd3ef744245-image.png
      E.g., first entry should be “Morgen um 16:30”

      The moment.calendar() function is used nowhere else in the module.

      I haven’t noticed this behaviour before, so I’m not sure if I have triggered this somehow or if it has been there before.

      Does anyone have a clue what the problem is?

      How to troubleshoot modules
      MMM-soccer v2, MMM-AVStock

      1 Reply Last reply Reply Quote 0
      • lavolp3L Offline
        lavolp3 Module Developer
        last edited by

        Well I have found the problem.
        But it seems to have been resolved with a recent code update

        For those interested:

        getLocaleSpecification: function(timeFormat) {
        		switch (timeFormat) {
        		case 12: {
        			return { longDateFormat: {LT: "h:mm A"} };
        			break;
        		}
        		case 24: {
        			return { longDateFormat: {LT: "HH:mm"} };
        			break;
        		}
        		default: {
        			return { longDateFormat: {LT: moment.localeData().longDateFormat("LT")} };
        			break;
        		}
        		}
        	},
        

        For case 24 The longDateFormat: hh:mm was wrong. It needs to be HH:mm.
        As said, was already changed.
        Thanks @MichMich

        How to troubleshoot modules
        MMM-soccer v2, MMM-AVStock

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Sam, technical setup by Karsten.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy