Q1. Am I correct in thinking that the DateTime Input component props.value return a formatted date rather than the millisecond timestamp?
Q2. How do I script calculation of the weekday (0 = Monday) from the DateTime Input props.value? The format in use is YYYY-MMM-DD (at the moment but I’d hate the application to break if I changed this later).
Q3. I’m generating a millisecond timestamp from dates (for history binding transform comparison) using millis = time.mktime(datetime.datetime.strptime(startDateTime, "%Y-%m-%d %H:%M").timetuple()) * 1000 # ms
Is there a better way?
Can you not just use system.date.getDayOfWeek(myDateTimeInput.props.value)?
Edit: my suggestion would return Mondays = 2, so you would have to add your own offset if you wanted your result to be zero-based on on Monday. The system function is 1-based with the week starting on Sunday.
I’m not sure if I understood, but I think you want to get a date from the millis returned by the history binding transform. Well that is not true, the historical bindings returns java.util.Date or even java.sql.Timestamp. What is happening is the perspective components decodes dates in Unix Based milliseconds.
That been said, if your object is a class of Date or Timestamp, use yourdate.getDate() method get unix based milliseconds. So, just use .getDate()