dhtmlXCalendar Start and End date limit - jquery-ui

I am using dhtmlXCalendar to create my calendar.
Is it possible to have a Start and End date limit to it so a user can cannot choose a date prior or beyond to a certain dates.
I want use to selected dates only between today and 2 years from today.
Any advice
Thanks
FArid

Yes it is possible using the setSensitiveRange() method Here is a simple example
<script>
var myCalendar;
function doOnLoad() {
myCalendar = new dhtmlXCalendarObject("calendarHere");
myCalendar.hideTime();
myCalendar.show();
myCalendar.setDate("2017-09-22");
myCalendar.setSensitiveRange("2017-09-22","2019-09-22");
}
</script>

Related

how to get current displaying page month in string in Fscalender in swift

I know how to get the month of current page but I want to know how to get the month of current page in string in fscalender please help me I'm new to iOS.
let values = Calendar.current.dateComponents([Calendar.Component.month, Calendar.Component.year], from: self.fscalenderobj.currentPage)
var CURRENT_MONTH = values.month
it's in integer form like in today month -> 5 ,I want it in name like May.
It's pretty simple.
let monthSymbols = Calendar.current.shortMonthSymbols (or monthSymbols dependeing upon what you need)
You can refer this
https://developer.apple.com/documentation/foundation/calendar/2293753-shortmonthsymbols

How to apply condition for built in validators

I have some requirements to check when user is creating a new issue. So on creation if they select particular component say "ABC", then duedate should be a mandatory field and if they forget to add that then it should throw an error. And the duedate should always be greater than 3 weeks than the today's date, if not it should display an error and until unless it's greater than 3 weeks they can not create issue.
I did see some inbuilt validators for required fields and duedate but it's applying to all component whereas I need only for particular component. Any suggestion/help ?
Thanks in advance!
If you are using Script runner Plugin, This can be achieved by writing a custom behavior.
For example Script runner Behavior:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil
import java.util.Date.*
def componentField= getFieldByName("component/s")
def dueDate= getFieldByName("Due Date")
dueDate.setRequired(false)
dueDateValue = dueDate.getValue() as Date
def today = new Date()
def threeWeekDate= today.plus(21)
if (componentField.getValue() == "ABC") {
dueDate.setRequired(true)
}
if(dueDateValue.before(threeWeekDate)){
dueDate.setError("You must choose a date after 3 weeks from today")
}

Viewers (per Link) jump to current date when they open file

I have a table in Google Sheets in the format:
A B C
Day Date inventory demand
Day2 Date2 inventory demand
etc.
Others are required to fill in inventory and demand every day. Thus, it would be helpful if they open the sheet they jump always to the current date. This could be done over HYPERLINK or code. However, as I am informed onOpen works for the editor, however not for viewers. As this is currently the case. When I open the file I jump to the current date, however people viewing and editing the file per link do not.
Could somebody please help me? Thank you.
I also do not understand, why creating a cell that jumps to the current date as an alternative does not work.
I tried various variations of
=HYPERLINK("l i n k&range=B"&MATCH("TODAY",B1:B1500,0),"Jump to today")
or
=HyperLink("LINK&range=B" &Match(Today(),B6:B,1),"JUMP to Today")
// jump to current date
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var range = sheet.getRange("B:B");
var values = range.getValues();
var day = 24*3600*1000;
var today = parseInt((new Date().setHours(0,0,0,0))/day);
var ssdate;
for (var i=0; i<values.length; i++) {
try {
ssdate = values[i][0].getTime()/day;
}
catch(e) {
}
if (ssdate && Math.floor(ssdate) == today) {
sheet.setActiveRange(range.offset(i,0,1,1));
break;
}
}
}
try like this:
=HYPERLINK("#gid=0&range=B"&MATCH(TODAY(); B6:B; 0)+5; "zu heute")
I found the options: Edit Triggers
To manually create an installable trigger through a dialog in the script editor, follow these steps:
From the script editor, choose Edit > Current project's triggers.
Click the link that says: No triggers set up. Click here to add one now.
Under Run, select the name of function you want to trigger.
Under Events, select either Time-driven or the Google App that the script is bound to (for example, From spreadsheet).
Select and configure the type of trigger you want to create (for example, an Hour timer that runs Every hour or an On open trigger).
Optionally, click Notifications to configure how and when you are contacted by email if your triggered function fails.
Click Save.
Google Explanation

Odoo 10 selection field after save error

I have a selection field and this function for list items in field by dynamically.
def get_years(self):
year_list = []
year = date.today().year+1
lastyear = date.today().year - 20
for i in range(int(lastyear),int(year)):
year_list.append((i, str(i)))
return year_list
this is the field,
year = fields.Selection(get_years, string='Yıl', default=get_current_year, restore="True")
and when I save the form, this field becomes unknown. I found what is the problem but I don't know the solution. Problem is compute function, when i write items like [(1997,1997),(2016,2016),(2017,2017)] it is working but i don't want to write hard code. How can i solve this problem? Thank you.
I found the solution, i don't need to create a new method and can use like;
year = fields.Selection([(num, str(num)) for num in range(1900, (datetime.now().year)+1 )],string='Year', default=datetime.now().year)
Thanks.

Saving and Querying a Date in GORM Grails

I have a database table TableA, which has a column 'theDate' for which the datatype in the database is DATE.
When I save a java.util.Date to 'theDate' through GORM it appears to save just the date value when I look at the data in the table by just executing select * from TableA.
However, when I run a query such as:
select * from TableA where theDate = :myDate
No results are found, but if I run something like;
select * from TableA where theDate <= :myDate
I do get results.
So it's like the Time is relevant.
My question is how do I save a Date and query for a Date ignoring the Time completely and just matching on an exact Date only?
Thanks.
note: I have also tried using sql.Date and util.Calendar but to no success.
clearTime()
You can use clearTime() before saving and before comparing to zero out the time fields:
// zero the time when saving
new MyDomain(theDate: new Date().clearTime()).save()
// zero the target time before comparing
def now = new Date().clearTime()
MyDomain.findAll('SELECT * FROM MyDomain WHERE theDate = :myDate', [myDate: now])
joda-time plugin
An alternative would be to install the joda-time plugin and use the LocalDate type (which only holds date information, no times) instead of Date. For what it's worth, I don't think I've worked on a project with dates without using the Joda plugin. It's completely worth it.
If you have date saved without clearing you could retrieve it using range, as Jordan H. wrote but in more simple way.
def getResults(Date date) {
def from = date.clearTime()
def to = from + 1
def results = MyDomain.findAll("from MyDomain where dateCreated between :start and :stop" ,[start:from,stop:to])
}
Your question may be a duplicate. See Convert datetime in to date. But if anyone has more recent information, that would be great.
If that doesn't help, you can hack it the way I might, with a BETWEEN restriction, e.g.
def today = new Date()
def ymdFmt = new java.text.SimpleDateFormat("yyyy-MM-dd")
def dateYmd = ymdFmt.format(today)
def dateTimeFormat = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
def startDate = dateTimeFormat.parse("${dateYmd} 00:00:00");
def endDate = dateTimeFormat.parse("${dateYmd} 23:59:59");
MyDomain.findAll("from MyDomain where dateCreated between ? and ?", [startDate, endDate])
It's definitely not pretty, but it may get you where you're going.
I figured it out.
I used DateGroovyMethods.clearTime to clear the time value before saving.
You can use the DB type date not datetime , in the filed type

Resources