Recurrence Rule +vCalendar - calendar

Recurrence Rule:
This property is identified by the property name RRULE. This property defines a rule or repeating pattern for a recurring vCalendar entity, based on the Basic Recurrence Rule Grammar of XAPIA's CSA. The value for the property is a pattern specification for the recurrence. The following is an example of this property:
RRULE:W2 TU TH // Every other week, on Tuesday and Thursday
RRULE:D1 #10 // Daily for 10 occurrences
RRULE:YM1 6 7 #8 // Yearly in June and July for 8 occurrences
Support for this property is optional for implementations conforming to this specification.
so for this "Recurrence Rule" is their any algorithm so that it is easy to develop it.

To me algorithm is what you have mentioned here .. i.e. "RRULE" .. you can "reverse-engineer" it to develop an application/module to output it back .. so its on to you (i.e. developer) to how to get output in this format.
I know that its not an easy job as I have played with around for a time before I came up with somewhat near solution. You can try some basic scheduler by creating a table, say events, with some of the fields like recurrence_type (daily, monthly, weekly, monthly_by_day, monthly_by_date), repeat_until, num_occurences etc.
To have all of the combinations of the RRULES it has to be very complex in order to output the desired format. I had tried it in PHP/MySQL.

Related

how to create a Salesforce formula that can calculate the highest figure for last month?

in Salesforce, how to create a formula that calculate the highest figure for last month? for example, if I have an object that keeps records that created in Sept, now would like to calculate its max value (in this case, should be 20 on 3/8/2019) in last month's (August). If it's in July, then need to calculate for June. How to construct the right formula expression? Thanks very much!
Date Value
1/9/2019 10
1/8/2019 14
2/8/2019 15
3/8/2019 20
....
30/8/2019 15
You can't do this with normal formulas on records because they "see" only current records (and some related via lookup), not other rows in same table.
You could make another object called "accounting periods" or something like that. Link all these entries to periods (months) in master-detail relationship. You'll then be able to use rollup summary with MAX(). Still not great because you need lookup to previous month to pull it but should give you an idea.
You could make a report that achieves something like that. PREVGROUPVAL will let you do some amazing & scary stuff. https://trailhead.salesforce.com/en/content/learn/projects/rd-summary-formulas/rd-compare-groups Then... if all you need is a report - great. If you really need it saved somewhere - you could look into reporting snapshots & save results in helper object...
If you want to do it without any data model changes like that master-detail or helper object - you could also write some code. Nightly batch job (running daily? only on 1st day of month?) should be pretty simple.
Without code - in a pinch you could make a Flow that queries records from previous month. Bit expensive to run such thing for August every time you add a September record but if you discarded other options...

What is the optimized way for queries on partial dates in GAE Text Search?

Need to get entities filtering by month instead of complete date values (E.g. Birthdays) using Google App Engine Text Search. On verifying GAE docs, I think it is not possible to query date fields by month directly.
So in order to filter them by month/date, we consider saving each date sub value like Date(DD), Month(MM) and Year(YYYY) as separate NUMBER field along with complete date field.
I verified locally that we can achieve by saving like this. But is this the correct way of saving dates by splitting each field when we want to query on date sub values?
Is there any known/unknown limit on number of fields per document apart from 10GB size limit in GAE Text Search?
Please suggest me.
Thanks,
Naresh
The only time NUMBER or DATE fields make sense is if you need to query on ranges of values. In other cases they are wasteful.
I can't tell from your question exactly what queries you want to run. Are you looking for a (single) specific day of the month (e.g., January 6 -- of any year)? Or just "anything in June (again, without regard to year)"? Or is it a date range: something like January 20 through February 19? Or July 1 through September 30?
If it's a range then NUMBER values may make sense. But if it's just a single specific month, or a single month and day-of-month combination, then you're better off storing month and day as separate ATOM fields.
Anything that looks like a number, but isn't really going to be searched via a numerical range, or done arithmetic on, isn't really a number, and is probably best stored as an ATOM. For example, phone numbers, zip codes (unless you're terribly clever and wanting to do something like "all zip codes in San Francisco look like 941xx" -- but even then if that's what you want to do, you're probably better off just storing the "941" prefix as an ATOM).

How to create a calendar event that repeats weekly for three months every year?

I want to be reminded about something every week every winter. Is that possible to achieve using the ical-/webcal-standard and Google Calender, Apple Calendar/iCal, Android Calender or similar?
(I searched quite extensively for which subdomain this questioned belonged to but the results were inconclusive, with a slight predominance for SO)
It's definitely possible with RFC 5545 recurrence rules.
You can create a WEEKLY RRULE that recurs in specific months only, like so:
FREQ=WEEKLY;BYDAY=MO;BYMONTH=1,2,12
The occurrences of this rule are all Mondays in January, February and December.
Check out the first 100 instances of such an event at http://recurrence-expansion-service.appspot.com/reaas?dtstart=20160104&rrule=FREQ%3DWEEKLY%3BBYDAY%3DMO%3BBYMONTH%3D1%2C2%2C12&skip=&max_instances=100&expansion_window_end=21000104&rfc2445=1
Changing the rule to DAILY would yield the same results, but might be more compatible with actual implementations.
However, I think most calendar UIs don't provide this level of control over recurrence rules.
update:
To create an all day event starting on Dec 15 2015 and recur on the same day of week use:
DTSTART;VALUE=DATE:20151215
RRULE:FREQ=WEEKLY;BYMONTH=1,2,12
The rule doesn't include March itself. To include March just append ,3 to the rule.

Orbeon calendar behavior

when using a calendar (input with a bind to a date), is there a way to control the interpretation of the input ?
For what I've seen:
1-31 will be the nth of the current month
32-99 is n day after the first of the current month
x0y is the yth day of xth month of the current year
Then it's a little random
511950 will give 05/01/2050
but 151950 will give 01/05/2050
From what i gathered, the control tries to interpret some symbols (any symbol, this includes digits) as separators.
So for example, 151950 is 1/1/50 instead of 1/5/1950 and because it's more than 50 years, the '50' is translated as 2050 instead of 1950.
This is pretty confusing for users, specially when they explicitly put the year with 4 digits and not only 2.
So i'm looking for a way to be a lot stricter. For instance only allowing the dd/mm/yyyy format (with explicit separators). The rest would render the value invalid instead of trying to translate it in something it is not.
Is there a way to do that ?
We're using Orbeon 3.8, and our forms are mostly in french, so dd/mm order.
The parsing is done with regular expressions. See the code here. (To be fair: this code is old!)
I suspect that the overflow conditions are simply a product of the JavaScript date object.
The only way to change this behavior as far as I know is to change the JavaScript code.

How do I store (and sort) vague date ranges?

I have a database which needs to store year ranges (such as lifespan) which in some instances aren't very specific. For example, as well as the usual '1960', we have 'c. 1960' for "around 1960", and 1960s for in the decade 1960, as well as 'nd' for no date which is distinctly different from NULL which would be until present.
What would be the best way to store these?
I was thinking of possibly storing the year as a string and appending 's' for decades and 'c' for circa, with 'nd' for no date... but this feels just wrong. Also, when sorting chronologically I need to sort by inserting 1960s items before c. 1960 items, which in turn are before 1960 items.
How do I do this properly?
Some example date ranges:
1957
c. 1957
c. 1957 - 1965
c. 1957 - 1960s
c. 1957 - present
c. 1957 - nd
Thanks for your help!
You can insert the earliest and the latest date possible for the range.
Like, exact date will be
Jan 1, 1960 Jan 1, 1960
, c. 1960 will be
Jan 1, 1960 Dec 31, 1960
, 1960s will be
Jan 1, 1960 Dec 31, 1969
etc.
Then you can order by the first date and the datediff:
SELECT *
FROM mytable
ORDER BY
start_date, DATEDIFF(end_date, start_date) DESC
Alternatively, you can store the expected value and the deviation instead of the start and end dates.
This sounds like a 'fuzzy logic' type problem. I would tackle it by using multiple columns:
Earliest Possible date
Earliest Certain date
Latest Certain Date
Latest Possible Date
Your examples might be represented as
1957,1957,1957,1957
1955,1957,1957,1959
1955,1959,1965,1965
1955,1959,1960,1969
1955,1959,NULL,NULL
1955,1959,9999,9999
I'm assuming 'c' means +/-2 years, a decade runs from '0 to '9, and 9999 is a flag value for 'nd'
Any use?
I think Quassnoi answer is good, alternativly you could generate a time dimension then reference it in a simular way (though your dimention may not need as many rows)?
You need to predetermine what your circa structure is OR allow for varience. Circa is often associated with classification of artifacts (books, photo's, writings) and other entities (unknown exact birth/death dates) where wide varience might be found. Keep in mind that reclassification of artifacts often occurs as more information is gained. Thus what Max has defined works, but I would also add a definative classification date and perhaps a column with a description and/or name of the classifier/entity defining the classification. You can determine if you need historical records of reclassification and how to handle that.
One other item of note regarding things of this nature - what calendar was in place defining the actual date for a day such as the The date Oct 4 (Julian) was followed by the date Oct 15 (Gregorian) which was a change made in 1582 and the similar change in 1751 that change Britian and its then colonies to the Gregorian calendar. Thus you need to determine the calendar in use which can be translated to present day calendars.
The point of this, is you MIGHT also need an identifier of the calendar in use assiciated with the determination and cite that as well.
Additionally, some events are associated with months denoted as "first month, second month etc." which, might be confusing as for instance the Quakers change where "first month" in 1751 was March but in 1752 it was January - especially noted when genealogy is the subject matter (as you imply) and births/deaths are the events.
For fun, toss in Caeser and Calends (first day of March) and his reform of the leap year/day where February 24 was the leap day as "second 6th day preceding the Calends" so there were two February 24ths (two 6th days) in leap years.
I point this out because the number of days in a leap year may in some instances vary your periods.
So, use a structure such as Max and/or Quassnoi propose, but possibly a bit more for the deliniation.
Citation for calendars and understanding: What is a calendar
"How do I store (and sort) vague date ranges?"
(A) Let's analyze with an above-average level of scrutiny what it means to be a date range. This means that there is a precise start date and a precise end date of the range.
(B) Let's analyze with an above-average level of scrutiny what it might mean to be a "vague" date range. To me, it seems like this is some kind of date range in which either the start date, or the end date, or both, are not precisely known, but in which one (or both) of those are THEMSELVES a range.
(C) It is a known fact that the usual mathematical notion of "ordering" (aka "total order") does not usefully apply to the concept of "ranges" (how would you decide that 1-3 is either greater or smaller than 0-6 ?). It IS theoretically possible to define such an ordering, based on e.g. "order on start dates first, and within equal start dates, on end dates", but such an ordering is never useful.
(D) And if the "start date" and/or "end date" of a range are themselves "vague" (i.e. those components are ranges themselves), then it is obvious why it is insane to try and meaningfully order such ranges.
So the answer to the "(and sort)" part is : "You don't, because you can't (in a meaningful way)".

Resources