display a date from the other calendar as selected - iphone

I have two calendar, when I select fist calendar value then my second calendar will shows previous calendar value +2 as selected ( i.e. when I select 2/07/2012 from first calendar then my second calendar will shows 4/07/2012 )
Is it possible?

Simply create a new date by adding the appropriate amount of seconds:
NSDate *newDate = [selectedDate dateByAddingTimeInterval:60*60*24*2];
and use that date as the basis for your new calendar.

Related

Calculate a Reference Date in DAX

Trying to nail down the syntax for a pretty straightforward problem.
I have a table called Events and a full-feature DATES table with a relationship between the Dates[Date] field.
Using the event name as a slicer, I trying to create a [First Monday] measure that will return the date of the first Monday of the month.
So for example, if my event date was 2/14/19, [First Monday] would return 2/4/19.
Your Date table needs to contain 2 columns:
Year-Month: for example, "2018-01"
Weekday Number: for example, 1 (for Monday); or Weekday Name (i.e, "Monday")
Then:
First Monday =
CALCULATE( MIN('Date'[Date]),
ALL('Date'),
VALUES('Date'[Year-Month]),
'Date'[Weekday Name] = "Monday")
How it works:
First, we need to access all dates in the Date table, so we use ALL()
Second, we need to see only dates for the current context year and month, for which we can use VALUES()
Third, for each month we only want Mondays, hence Date[Weekday] = "Monday"
All this unfiltering/filtering generates a set of Mondays for the Year-Month visible in the current filter context. All we need to do now is to find the earliest of the Mondays using Min(Date).

date is not printing properly for UIDatePicker

I have a date picker & above it I have 1 button as Done. On clicking this button I print the date picker date.
When I scroll the date picker and print date, it works fine. Below is the code I have
print("date selected===\(myDatePicker.date)")
The problem comes when I don't scroll the datepicker and click done button.
The scenario is I have set datepicker maximumDate as year 2000 (currentYear-18). Below is code I have used.
var dayComp = DateComponents()
currDate = Date()
dayComp.year = -18
currDate = calendar.date(byAdding: dayComp, to: currDate)!
mDateFrom.maximumDate = currDate
Now as datepicker is going back 18 years, I see date picker with date as 25/Jul/2000 however when I click Done button it print today date only.
It gives proper date only when I scroll datepicker.
Any idea why this is happening?
I believe you need to set the default date displayed by the date picker once you create a datePicker based on what you want it to be. Because the default value of this property is the date when the UIDatePicker object is created and that's why whenever you print the value of date picker without spinning, it shows you the current date however if you spin the datePicker, this property is being set properly and you get the right date printed.
//you can use date property to set or get
myDatePicker.date = yourFormattedDateHere
Setting date property animates the date picker by spinning the wheels to the new date and time, if you don't want any animation to occur when you set the date, use the setDate(_:animated:) method, passing false for the animated parameter.

MomentJS date string adds one day

I don't understand why this date is saved as +1 day:
startdate = "2017-11-29T23:59:59.999Z";
var new_date = moment(startdate).format('DD/MM/YYYY'); // --> gives 30/11/2017
But if I do:
startdate = "2017-11-29";
var new_date = moment(startdate).format('DD/MM/YYYY'); // --> gives the correct date 29/11/2017
Any ideas?
Here is a jsfiddle showing this: http://jsfiddle.net/jbgUt/416/
Thanks!
If a time part is included, an offset from UTC can also be included as +-HH:mm, +-HHmm, +-HH or Z.
Add utc() to avoid it.
moment(startdate).utc().format('DD-MM-YYYY')
or
moment.utc(startdate).format('DD-MM-YYYY')
If you want to parse or display a moment in UTC, you can use moment.utc() instead of moment()
Late to the party on this one, but I did just convert a few of our product's date-time objects to https://moment.github.io/luxon/
Takes out the need for the .utc() method above.

How to create a specific date in Google Script

I have a spreadsheet that asks people to enter in a day of the month when we need to send out a bill. What I want to do is create a calendar event based on that. So, essentially what I need is an event that starts at the current month, day from the spreadsheet, and continues to a specified point in time.
var monthlyDate = row[6]; // Seventh column, monthly date of payment
var curDate = new Date();
var curMonth = curDate.getMonth();
var curYear = curDate.getYear();
curDate.setDate(curMonth, monthlyDate, curYear);
Logger.log("Day of month: %s", monthlyDate);
Logger.log("Current Date: %s", curDate);
Logger.log("Current Date: %s", Date());
What I'm seeing is that the monthly date is coming in as a float "6.0" for example, and no matter what I enter in for monthlyDate in the setDate line, it keeps setting the date to 10/9/15 (Today is 10/15/15). I've hard-coded that value to many different numbers, but for some reason it's just not working.
How can I create a date (in any format) that follows the scheme "Current Month / Day from Speadsheet / Current Year" ?
The getMonth() method returns a "zero-indexed" number. So, it returns the number 9 for the 10th month. setDate() doesn't set the date, it sets the "Day of the Month". The name of that method is misleading.
Documentation - setDate()
So, the last two parameters that you are using in setDate() are doing nothing. You are setting the day of the month to 9.
If you want to set multiple date parameters at the same time, you need to use the new Date() method:
var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
The month parameter accept values from 0 to 11, 0 is Jan and 11 is Dec
Date Reference

How can I set the first day of the week to monday in dojox.calendar (columnview)

How can I set the first day of the week to monday in dojox.calendar (columnview)?
http://dojotoolkit.org/reference-guide/1.9/dojox/calendar.html
In the documentation it says there is a startDate property in the columnView,
but you have to set a date. How can I set the startDate on Monday?
If I set a startDate, nothing changes.
startDate * - The date of the first column,
Properties with an (*) are computed by the calendar widget.
The calendar renders the startdate from the locale of the browser.