Dexterity Custom Year Range on Date Field - plone

I'm building content type using dexterity. We've date of birth field and by default year range is +- 10 year from current year.
Date field need to be modify and year should start from 1950. I did bit goggling and couldn't find right information I'm after.
Below is my DOB field definition.
dob = schema.Date(
title=_(u"Date of Birth"),
)
Any advise or reference would be great.
Thanks in advance.

Use the collective.z3cform.datetimewidget (https://github.com/collective/collective.z3cform.datetimewidget)
for your field.
This widget has a yearRange attribute.
By default it gets the range defined in site_properties: calendar_starting_year and calendar_future_years_available
Check the documentation if you don't know how to setup the widget
BTW since Version 1.2.4, You can set the min/max value on the field.

Related

Google Docs Forms - need Pre-fill Date & Time Entry with current date and current time

Google Forms I need Pre-filled current Date & current Time Entry in date and time fields of my google form. How to do it
My solution is to make the Date field optional. The default is to assume the todays date which is what you get from the timestamp field. In case it needs to be anything else you can enter it manually.
A simple code-free solution is to make separate sections in your form and use the feature that routes users to different sections based on responses. The first section asks whether the form is for the current date/time. If yes, you use the timestamp as the date and time and route the user to the main section with your questions. If not, route them to a section to set the date and time, and then after that route them to the main section.
2023 Solution
-Google Forms has updated how dates are passed through URL parameters.
Instead of passing each component of a date as a separate param, you now pass them using the same syntax as all other fields using the YYYY-MM-DD format for your date value.
Here is an example URL:
`https://docs.google.com/forms/d/e/${formId}/viewform?usp=pp_url&entry.${dateEntryFieldID}=${YEAR}-${MONTH}-${DAY}`

How to set a date for WKInterfaceDate

Can WKInterfaceDate show a date & time different from the current values?
If yes, how can I set a different date?
apple documentation says:
A WKInterfaceDate object is a custom label that displays the current
date or time. Use this object when you want to display date or time
information without further interaction from your WatchKit extension.
At runtime, use the date object to configure the appearance of the
date and time information being displayed.
For different date you can simply create label and set it's text to a String that you create with NSDateFormatter out of some NSDate.

Cognos 10.2 - date range default earliest vs today

Very simple question (hopefully) but I can't find the answer anywhere. I have two seemingly identical date prompts for optional date ranges. One defaults to today's date. The other defaults to 'earliest' and 'latest'. But I can't for the life of me find the setting that controls this.
(I'm not trying to do anything advanced such as dynamical defaults, using javascript.)
Please help. Thanks.
A single-select date prompt with the Required property set to 'No' and the Range property set to 'Yes' will show the Earliest and Latest radio buttons and have them selected as default. When the Required property is set to 'Yes' the date prompts default to the current date. Thus, your two date prompts likely have different settings for the Required property.

How to ensure that an object does not have the same id?

Here is my problem:
I have a custom Dexterity content type that its ids must be always a computed value out of two fields (week and year).
What I need to ensure is that if someone tries to create a new object of that content type and uses an already existing (week, year) tuple Plone needs to give an error and ask the user to change either the week or year fields.
So I not only need to check that no other object already exists with that week and year values, but also that the object id is consistent (WWYY, WW for week and YY year is the format).
I first thought of an invariant on the content type interface, but that still leaves the id up to INameChooser.
So registering an INameChooser for the parent folder (fortunately I have a specific parent folder for that content type) can be enough?

Drupal Views how to filter items overlapping a date range

in Drupal I have used CCK to add a datetime field to my custom data type. It inserts start date and end date fields. That is what I want. Now, I want Views to filter and show only the items that have the daterange (start date and end date) overlapping today's date. Any ideas on how to set it up on Views? What I think is strange is that the date fields of my custom content type don't seem to appear on the Views list when I am trying to add a filter. Thanks.
You should enable the Date module, and use the Date specific filtering. It will work much easier for you than getting CCK Date to work.

Resources