I am wondering why OpenERP's date and datetime fields are limited with years?
If I click on year tab to select a year, it shows only 21 years in one go. if I want to select an older year, I am forced to select one older year from the list then it will open next 21 years list for me. It is annoying me.
Is there a way to increase the limit of years so that it is possible to scroll at least into a good range of years like 1950,2020 in one go?
I think I will have to play with javascript but don't know how. Can someone help me out ?
Right I understand your point here, but this is form jquery lib dattime picker yearrange is -10 abd +10 bydefault, But yes for you can increasr to limit you want I have given patch below for the trunk smiler thing als can be done it 6.1 OpenERP
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js 2012-10-31 15:03:24 +0000
+++ addons/web/static/src/js/view_form.js 2012-11-02 05:08:29 +0000
## -2328,7 +2328,8 ##
changeYear: true,
showWeek: true,
showButtonPanel: true,
- firstDay: Date.CultureInfo.firstDayOfWeek
+ firstDay: Date.CultureInfo.firstDayOfWeek,
+ yearRange:"c-30:c+30"
});
this.$el.find('img.oe_datepicker_trigger').click(function() {
if (self.get("effective_readonly") || self.picker('widget').is(':visible')) {
Here you can see to crease the Year range -30 will allow you increase previous year range and +30 will increase upcoming year range. This are lib config can be over rideen anytime.
Thank You.
Related
I actually tried to restrict users to pick dates within 2 years from today in Datepicker.
So now there is one issue that is coming up that when in zoom out too much (By zooming out I mean when we click on the month name it will zoom out to all months and and similarly all month to all year)
this is the zooming out I am talking about
but if I zoom out to such an extent where it shows the calendar in group of a decade or a century I am not able to zoom in back or I mean not able to go back to the calendar view where I could select dates.
so is there a way to restrict users to zoom out after a level? or is there a way to fix it?
My datepicker version is Bootstrap v4.1.1
This is the code we are using
tz_today Is today's date in yyyy-mm-dd format.
endDate = new Date(new Date().setFullYear(new Date().getFullYear() + 2));
pickDate = new Date(pickDate); // in yyyy-mm-dd format
$('#Datepicker').datepicker('destroy').datepicker({
todayHighlight: true,
beforeShowDay: function (date) {
$highlight = calendar_highlight_classes(highlight_dates, pickDate, date);
return $highlight;
}
}).datepicker('setStartDate', new Date(tz_today))
.datepicker('setEndDate', endDate);
Well for me MaxViewMode worked like a charm. By default, it is set as 4 but we can change it acc. to our preference
days(0) -> month(1) -> year(2) -> decade(3) -> century(4)
MaxViewMode: 2 - to limit users to go up to years view mode
my code to limit users to go only till year
$('#Datepicker').datepicker('destroy').datepicker({
todayHighlight: true,
endDate: endDate,
maxViewMode: 2
});
Here is the documentation https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#maxviewmode
I have used moment.js to calculate 30 days limit in a form field where I have used daterangepicker.js to pick the date. I have disabled all previous date from current date and all dates after 30 days counting from current date. Everything was working fine until the "year" nation attacked(hehe git it?).
My date calculation was working fine using moment.js, but as the year is changing, everything breaks. Whenever I change the year to 2021 from 2020 every date becomes disabled. Like I want to post something today(22/12/2020) and want to set the deadline next year, to do that when I change the year every date becomes disable. Before changing the year I can see the dates of next year enabled and I can select it, it works fine like that. But whenever I change the year dates becomes disabled.
This is my current code to calculate date limit:
$('input[name="application_deadline"]').daterangepicker({
locale: {
format: 'DD-MM-YYYY HH:mm'
},
singleDatePicker: true,
showDropdowns: true,
startDate: moment(),
endDate: moment().subtract(-29, 'days'),
minDate: moment(),
maxDate: moment().subtract(-29, 'days')
});
My code technically works if I disable the line:
maxDate: moment().subtract(-29, 'days')
Then every date is enabled after the current date but removes the 30 days limit which I require to be working.
I have attached two screenshots of before and after changing year for the reference.
What you're describing sounds like a bug in daterangepicker.js. To reproduce, I've tested latest version from their website using jQuery 3.5.1.
Unfortunately I'm not able to reproduce what you're describing. Did you try updating to latest version 3.1?
When using the jQuery UI Datepicker and starting the week on a Sunday, the week numbers are incorrect. For example, 3rd Jan 2016 should be week 1 as all of the dates (3rd to 9th) are in the same year. But as you can see in the screenshot below, the UI shows it as week 53.
Here is the code to render the datepicker:
$("#datepicker" ).datepicker({
showWeek: true,
firstDay: 0
});
So nothing special, other than showing the week numbers and starting the week on Sunday instead of Monday (as per default).
Here is a fiddle of the issue: https://jsfiddle.net/vLqabmmz/
Due to the fact that this seems like a bug in jQuery UI. I'm posting the possible answer being the reporting of this as a bug to the jQuery UI team here: https://bugs.jqueryui.com/ticket/14907#ticket
i checked further and iso8601Week() method of jqueryUI is working fine, the problem is in its representation (the layout).
If you extract the value of the week you can see that the standard is followed and is fine. 3-rd is week 53 and after that 4 ... 7 (which is the first Thursday of the year and this is the week number 1). You can check with the code below.
$(function() {
$( "#datepicker" ).datepicker({
showWeek: true,
onSelect: function(dateText, inst) {
$(this).val("'Week Number '" + $.datepicker.iso8601Week(new Date(dateText)));
}
});
});
As seen from documentation for calculateWeek here:
This function uses the ISO 8601 definition of a week: weeks start on a Monday and the first week of the year contains January 4.
So comments are right qualifying this as a bug. While this is not resolved yet, you can overcome this easily by setting firstDay to 1 like this:
$("#datepicker" ).datepicker({
showWeek: true,
firstDay: 1
});
Week number would be correct, it is easier than rewrite calculateWeek, only difference is that week will start on Monday instead on Sunday. Note that default behavior sets firstDay to 0.
Here is a display of the jQuery calendar for the first week of 2017 - fully contained in a new year.
Yet, the week number is shown as 52 of year 2016 (wtf).
To me it looks like a bug to be corrected, otherwise there is no reason to display the week number.
https://en.wikipedia.org/wiki/ISO_week_date:
The first week of a year is the week that contains the first Thursday of the year (and, hence, always contains 4 January).
You should update locale:
moment.updateLocale('en', {
week: {
dow: 1,
doy: 1
}
});
I would like to know how to set a day range on moment.js, I just need to show just the weekdays not the weekends.
At the moment I'm using this:
Database: moment().subtract('days', 1).toDate(),
{{Database}}
I use this to show the database refresh but on weekends there are no updates.
Based on your comments, I think that this does what you want:
m.subtract(m.day() === 1 ? 3 : 1, 'days');
If m is a moment, this will subtract 1 day except for on Monday (where m.day() === 1) where it will subtract 3 days. This means that m will go through the days backwards like Wednesday, Tuesday, Monday, Friday, Thursday, etc.
If this is what you want, I am happy to help you modify your question to make it more clear. If not, please edit it to explain what you are trying to do.
I'm trying to create a textbox that accepts mm/yy. For some reason this doesn't like dates beyond 2032. Can anyone tell me why not and what the solution is?
Update: Problem appears to be strictly a 2 digit year issue.
<input type="text" class="miniTextBox" id="${id}_Date" name="${id}_Date" maxlength="5"
data-dojo-attach-point="indate"
data-dojo-type="dijit/form/DateTextBox"
data-dojo-props="constraints:{fullYear: false, datePattern: 'MM/yy', max: '2099-12-31'},
popupClass: 'dojox.widget.MonthAndYearlyCalendar'"
promptMessage="Example: 10/14" />
If it makes any difference, the following information may be helpful:
Uses Dojo 1.8
This is part of a widget template
There is a postCreate modification on this widget to set the fullYear constraint to false.
It does not use the standard popup calendar, and it doesn't matter if the date is entered by the popup or from the textbox.
the problem appears to be strictly a 2 digit year format issue - it works fine when the date format is changed to MM/yyyy and fullYear is true.
In case anyone is still wondering, this is expected behavior. See documentation.
When two digit years are used, a century is chosen according to a sliding window of 80 years before and 20 years after present year, for both yy and yyyy patterns.
2033 was just outside that window in 2013 and 33 was interpreted as 1933.