I am using datepicker to select date,
and my source code for addEventlistener is here.
$.picker.addEventListener('change',function(e){
var date = e.value;
Ti.API.info(date); // shows '[INFO] : 2014-04-07 21:28:34 +0000' on console
date.substring(0,10);
});
Ti.API.info(date) shows correct data ,but
date.substring(0,10); shows error like this below
[ERROR] : Script Error {
[ERROR] : backtrace = "#0 () at :0";
[ERROR] : line = 143;
[ERROR] : message = "'undefined' is not a function (evaluating 'date.substring(0, 10)')";
[ERROR] : name = TypeError;
[ERROR] : sourceId = 329234912;
[ERROR] : sourceURL = "file:///Users/temp/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/2E7B2C43-653A-4E38-BB04-F820AB2C3BC2/matomato.app/alloy/controllers/index.js";
[ERROR] : }
convert date to String ,then you will be able to use substring
$.picker.addEventListener('change',function(e){
var date = e.value;
date= date.toString(); // check it
date.substring(0,10);
Ti.API.info(date); //'2014-04-07'
});
For dates you could use:
var day = date.getDate();
var month = date.getMonth();
var year = date.getFullYear();
var newdate = year + "-" + month + "-" + day;
Related
I am trying to map a LocalDate to a SQL Date, but am receiving this error:
java.lang.IllegalArgumentException: Undefined filter parameter
[afterDateLocal]
I can't provide a reproducible example, but here's the code of the ListingRepositoryImpl:
if (!queries.get("checkInDate").get(0).equals("undefined")) {
Filter afterDateFilter = session.enableFilter("afterDateFilter");
String afterDate = queries.get("checkInDate").get(0);
LocalDate afterDateLocal = LocalDate.parse(afterDate);
System.out.println("After date: " + afterDateLocal);
afterDateFilter.setParameter("afterDateLocal", afterDateLocal);
} else {
session.disableFilter("afterDateFilter");
}
And the filters defined on the entity listing:
#Entity
#Table(name="listing")
#FilterDefs({
#FilterDef(name="priceFilter", parameters=#ParamDef(name="priceComparison",type="double")),
#FilterDef(name="beforeDateFilter", parameters=#ParamDef(name="beforeDateLocal", type="date")),
#FilterDef(name="afterDateFilter", parameters=#ParamDef(name="afterDateLocal", type="date"))
})
#Filters({
#Filter(name="priceFilter", condition="price <= :priceComparison"),
#Filter(name="beforeDateFilter", condition=":beforeDateLocal <= date"),
#Filter(name="afterDateFilter", condition=":afterDateLocal >= date")
})
I am using Hibernate 5.5.7 so I expect LocalDate to work.
date was not defined in the database, which is why I received the error.
i had same problem ("Undefined filter parameter date value") with creating a filter with the LocalDate and i tried this at the type attribute (type = "java.time.LocalDate") and it worked for me.
I use the official FullCalendar VueJS component, and I would like to update the current range displayed in the view (DayGridMonth here) : 1 month, 2 months, 3 months, custom period
According to the "documentation", the visibleRange property can be updated thanks to the function setOption() (https://fullcalendar.io/docs/visibleRange), but it doesn't work for me : the property is well updated in component, but the view wasn't updated.
I also tried to update state manually, without result.
This is my draft function to do this
updateCurrentDate: function () {
const calendarApi = this.$refs.fullCalendar.getApi();
const date = new Date(calendarApi.getDate());
let endRange;
this.currentPeriodRange = calendarApi.state.dateProfile.activeRange;
this.currentPeriodLabel = moment(date).format('MMMM YYYY');
if (this.currentView === 'month') {
endRange = moment(this.currentPeriodRange.start).add(2, 'month');
this.currentPeriodRange.end = endRange.toDate();
// Not working
calendarApi.setOption('visibleRange', this.currentPeriodRange);
// No one of these test work
calendarApi.state.dateProfile.activeRange = this.currentPeriodRange; //
calendarApi.state.dateProfile.currentRange = this.currentPeriodRange;
calendarApi.state.dateProfile.renderRange = this.currentPeriodRange;
}
if (this.currentPeriodRange.start !== this.currentPeriodRange.end) {
this.currentPeriodLabel = this.currentPeriodLabel + ' - ' + endRange.format('MMMM YYYY');
}
return;
},
Thanks for reading and answering
I'm using FullCalendar v4-alpha-3 with the RRule plugin to generate recurring events. It works as expected with only one problem: how do I modify a recurring event to account for months with fewer days than the starting month in a series?
For example, if the first monthly occurrence happens on January 29, 2019; the event will be repeated on the 29th of all subsequent months except in February since it only has 28 days (leap years excluded).
I've tried resetting dtstart to the first day of the following month. It works, except the event is no longer recursive.
Here's a stripped down snippet of my setup:
let calendar = new Calendar(calendarEl, {
plugins: [ rrulePlugin ],
events: [
{
rrule: 'DTSTART:20190129 RRULE:FREQ=MONTHLY;UNTIL=20200130;COUNT=13;BYMONTHDAY=29'
}
],
eventRender: function(info) {
...
// reset start date to the first day of the following month
// if current month has fewer days than base month
let start = event.start;
let day = start.getDate();
let now = new Date();
let currentMonth = now.getMonth();
let currentYear = now.getFullYear();
let daysInCurrent = getDaysInMonth(currentMonth + 1, currentYear);
let nextStart = start;
if (day > daysInCurrent) {
nextStart = new Date(currentYear, currentMonth + 1, 1);
event.setStart(nextStart);
event.setEnd(null);
}
}
});
I'd appreciate any insight.
Not quite the solution I hoped for, but RRule's bysetpos property seems to offer the next best alternative as it allows for a fallback date in case the one specified doesn't exist.
For example, the following would generate an occurrence on the 30th of every month; or the last day of the month if the 30th doesn’t exist:
FREQ=MONTHLY;BYMONTHDAY=28,29,30;BYSETPOS=-1.
Sourced from: https://icalevents.com/2555-paydays-last-working-days-and-why-bysetpos-is-useful/
I know this is an old question but maybe this will be usefull for someone:
I'm using momentjs library
monthly:
let endofmonth = moment('2020-02-29', "YYYY-MM-DD").endOf('month').format('DD');
let curday = moment('2020-02-29, "YYYY-MM-DD").format('DD');
single_event.title = title;
single_event.rrule = {};
single_event.rrule.freq = 'monthly';
single_event.rrule.dtstart = start_date;
single_event.rrule.interval = reminder_interval;
single_event.rrule.count = reminder_count;
if(endofmonth == curday){
// Checking if given day of the month is last
single_event.rrule.byweekday = ['mo','tu','we','th','fr','sa','su'];
single_event.rrule.bysetpos = -1;
}
else{
single_event.rrule.bymonthday = parseInt(curday);
}
calendar_events.push(single_event);
var calendar = new FullCalendar.Calendar(calendarEl, {
...
events: calendar_events
});
yearly:
single_event.title = title;
single_event.rrule = {};
single_event.rrule.dtstart = start_date;
single_event.rrule.count = parseInt(reminder_count);
if(endofmonth == curday){
// Checking if given day of the month is last
single_event.rrule.freq = 'monthly'; // Will work as yearly if interval is 12
single_event.rrule.interval = parseInt(reminder_interval)*12;
single_event.rrule.bymonthday = [28,29,30,31];
single_event.rrule.bysetpos = -1;
}
else{
single_event.rrule.freq = 'yearly';
single_event.rrule.bymonthday = parseInt(curday);
}
calendar_events.push(single_event);
var calendar = new FullCalendar.Calendar(calendarEl, {
...
events: calendar_events
});
How can I get the time from a json where I have values like:
"time": ["1507457400000", "1507458600000"] //Strings
In Javascript I could do something like
new Date(1507457400000) // return Sun Oct 08 2017 12:10:00 GMT+0200
new Date(1507457400000).getHours() // return 12
new Date(1507457400000).getMinutes() // return 10
But I have no idea how to get the time using kotlin. Any idea what is the best way to get the time from the data I have?
val date = SimpleDateFormat("HH:mm").format(Date((1507457400000 / 1000)))
Use this:
val calendar = Calendar.getInstance()
calendar.timeInMillis = 1507457400000
val date = calendar.time
if you have the millisecond in a string like str:
val calendar = Calendar.getInstance()
calendar.timeInMillis = str.toLong()
val date = calendar.time
for hour and min:
val h = calendar.get(Calendar.HOUR_OF_DAY)
val m = calendar.get(Calendar.MINUTE)
val result = h.toString() + ":" + m.toString()
In my MVC application I am storing dates in UTC. In my view I am doing this to show the dates in date time pickers in local time
<div class="datetimepicker">#(Html.Kendo().DateTimePickerFor(m => m.StartDateTime).Value(Model.StartDateTime.ToLocalTime()))</div>
The problem is that when the datetimes arereturned in the post methods back to the server they are returned in local time. Is there a way from the view to return the datetimes in UTC?
Hi datetimepicker in kendo i dono abt it,but just a thought if u can get the value from datetimepicker and pass through a function as below which converts to UTC and then send it to server , i believe ur task is complete..sry if i am wrong...
function convertToUtc(str) {
var date = new Date(str);
var year = date.getUTCFullYear();
var month = date.getUTCMonth()+1;
var dd = dategetUTCDate();
var hh = date.getUTCHours();
var mi = date.getUTCMinutes();
var sec = date.getUTCSeconds();
// 2010-11-12T13:14:15Z
theDate = year + "-" + (month [1] ? month : "0" + month [0]) + "-" +
(dd[1] ? dd : "0" + dd[0]);
theTime = (hh[1] ? hh : "0" + hh[0]) + ":" + (mi[1] ? mi : "0" + mi[0]);
return [ theDate, theTime ].join("T");
}
Your question is a good one and the approach that we suggest is covered in this code library article.