Have a look at the year after setWeek
d = Date.today()
Wed Dec 26 2012 00:00:00 GMT+0000 (GMT Standard Time)
d.getWeek()
52
d.setWeek(52)
Mon Dec 23 2013 00:00:00 GMT+0000 (GMT Standard Time)
Anyone knows what this is about? Have I misinterpreted how the setWeek function should work?
I have found an issue in the datejs tracker with this same problem. It's from 2011, though it's still marked as new: setWeek issue
So regarding yor question of "Have I misinterpreted how the setWeek function should work?" I would say that it's a bug in the jdate code.
If you have a look at the datejs source code you will see that setWeek will always move to the Monday of the target week n:
Date.prototype.setWeek = function (n) {
return this.moveToDayOfWeek(1).addWeeks(n - this.getWeek());
};
see: datejs: svn/trunk/src/core.js
Related
Imagine that we have a timestamp, for example 1571140569 (Tuesday, 15 October 2019 11:56:09). I need to get the start, in this case Tuesday, 15 October 2019 00:00:00. Then i need to apply timezone, imagine "America/Lima" (GTM -7h), we want to show Tuesday, 14 October 2019 07:00:00
I use this code
moment_timezone(1571140569).startOf("day").tz("America/Lima");
But doesn´t work. Return Tuesday, 15 October 2019 00:00:00.
So: Somebody know how can i get the start of timestamp and then apply timezone?
Hope this helps you to get the output you are expecting.
const date = moment(moment.unix(1571140569).utc().startOf('day')).tz("America/Lima").format('LLLL');
console.log(date);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.23/moment-timezone-with-data.js"></script>
I have purchased a Theme in wp that is using https://fullcalendar.io/
Current Week Structure is → Sun Mon Tue Wed Thu Fri Sat, but
I want it to be like → Mon Tue Wed Thu Fri Sat Sun
This is the theme Demo from where I have purchased Click Here →
The theme owner aid contact to https://fullcalendar.io/, but on their website I find that I have to seek StackOverflow for the support.
You probably have to make a change to the javascript of the theme to accomplish this. Check out the file events.js in the js directory of your theme. Starting on line 48 try replacing this code:
jQuery('#event-calender-widget').fullCalendar({
aspectRatio:1,
events: calenderAjax.events,
With:
jQuery('#event-calender-widget').fullCalendar({
aspectRatio:1,
firstDay:1,
events: calenderAjax.events,
Good luck!
you may take a look at firstDay option of full calendar
I have this this date
<p am-time-ago="Thu Oct 15 21:53:55 IST 2015"></p>
it shows
[$parse:syntax] Syntax Error: Token 'Oct' is an unexpected token at column 5 of the expression [Thu Oct 15 21:53:55 IST 2015] starting at [Oct 15 21:53:55 IST 2015].
2015-10-13T18:49:52.888Z
it shows Token 'T18' is an unexpected token at column 11 of the expression [2015-10-13T18:49:52.888Z] starting at [T18:49:52.888Z].
Moment isn't parsing the date correctly because it is in an unsupported format.
For the first one, change IST to the offset (+05:30).
For the second, get rid of the T and Z, and put a space between the date and time.
Edit: Note that more recent versions of moment js don't support TZ abbreviations anymore, like IST or CST or UTC. That function was deprecated in 1.6.0.
This question already has answers here:
Moment.js internal object what is "_d" vs "_i"
(2 answers)
Closed 6 years ago.
I'm using moment.js in my web application and encountered a bug where the time on many objects change to midnight at some point. I'm still trying to hunt down what, if anything triggers this change, but looking at one of the moments, I noticed the _i property shows the original / correct time.
Below is the developer console output of one of the moments in question, mm
_d: Thu Apr 02 2015 00:00:00 GMT-0400 (EDT)
_f: "YYYY-MM-DDTHH:mm:ssZ"
_i: "2015-04-02T12:10:43-04:00"
_isAMomentObject: true
_isUTC: false
_isValid: true
_locale: Locale
_pf: Object
_tzm: -240
mm.toISOString()
// "2015-04-02T04:00:00.000Z"
moment(mm._i).toISOString()
// "2015-04-02T16:10:43.000Z"
What does the _i represent, and why doesn't it match the string output?
It turns out the bug was caused by a combination of 2 bad assumptions I had
calling startOf() mutates the moment, which I did not realize
the Immutable data structure I'm using ignores Objects with custom prototypes, so the moment objects were left mutable
The result was that another part of the application was able to mutate moments that I expected to be immutable
To answer my question though, I found the following
_i is the input when the moment object was originally created, and does not appear to change
_d is a Date object representing the date value after any mutations
mm = moment("2015-04-02T12:10:43-04:00")
mm._i // "2015-04-02T12:10:43-04:00"
mm._d // Thu Apr 02 2015 12:10:43 GMT-0400 (EDT)
mm.startOf('day')
mm._i // "2015-04-02T12:10:43-04:00"
mm._d // Thu Apr 02 2015 00:00:00 GMT-0400 (EDT)
I am doing some work on a fairly old system and need to know when a couple of processes started. When I use "ps -ef" one says October 18 and the other March 23. We haven't got to October 18 this year so I'm not sure if this is October 18 last year or the previous year. The uptime command is showing 2419 days (6.6 years!) so it's possible the Oct 18 is from earlier than 2012. This is a HP-UX system. I have done a bit of googling and none of the answers I came across worked, eg ps -o, looking in the /proc dir.
cfgmgr 9947 9943 3 Mar 23 ? 6831:32 /home/cfgmgr/bin/snmpagt
root 24338 1 0 Oct 18 ? 2628:13 /usr/sbin/snmpdm -tcplocal
PS can only show the date because as per PS documentation at MAN page
'Only the year will be displayed if the process was not started the same year ps was invoked, or "mmmdd" if it was not started the same day, or "HH:MM" otherwise.'