Time and date function in CLIPS - time

is there a way to get current date or time (better if timestamp) from
CPU in CLIPS?
Thank you,
Nicola

You can call the time function to retrieve the number of seconds that have passed since a prior date (defined by the particular implementation used by the platform specific library function called by CLIPS).
CLIPS> (time)
900973.658508
CLIPS> (time)
900977.658599
CLIPS>
You can also download and compile code for the 63x branch of CLIPS (https://sourceforge.net/p/clipsrules/code/HEAD/tree/branches/63x/core/) and use the gm-time and local-time functions provided.
CLIPS> (gm-time)
(2016 6 10 20 12 52 Friday 161 FALSE)
CLIPS> (local-time)
(2016 6 10 15 12 55 Friday 161 TRUE)
CLIPS>
The gm-time function returns Greenwich Mean Time and the local-time function returns local time. The values returned in the multifield are year, month, day, hour, minutes, day of week, days since beginning of year, and daylight savings time.

Related

Assigning numbers to corresponding time durations on Google Sheets

I am trying to assign the numbers 1-6 for various time durations.
For example if the duration is 00:01 (1 minute) to 04:00 (4 hours), I want a number designation of "1."
04:01 to 08:00, I want a designation of "2."
08:01 to 12:00, I want a designation of "3."
12:01 to 16:00, I want a designation of "4."
16:01 to 20:00, I want a designation of "5."
20:01 to 24:00, I want a designation of "6."
I have done some research into writing a formula like this, but have not had any luck. Thank you for you time!
try:
=ARRAYFORMULA(IFNA(VLOOKUP(A1:A*1, {
"00:01:00"*1, "1.";
"04:01:00"*1, "2.";
"08:01:00"*1, "3.";
"12:01:00"*1, "4.";
"16:01:00"*1, "5.";
"20:01:00"*1, "6."}, 2, 1)))

Laravel How to Extra Rows with Duplicates

I am having problem constructing my query to find rows containing duplicated values specifically in ('day','time_from',''time_to').
The problem is that the value of 'day' column could be 1 or 2 combination(M or M-W)
The query should extract the following ('M-W','7:00','8:30') and ('M','7:00','8:30') as duplicate.
Is there any workarounds with these? Quite new to Laravel.
This my current query which can only extract if ('day') are exact value.
$dupeTeacher = DB::table('load_schedule')
->select('time_from', 'time_to', 'day')
->groupBy('time_from', 'time_to', 'day')
->havingRaw('COUNT(*) > 1');
$dupliTeacher=DB::table('load_schedule')
->select('load_schedule.*')
->joinSub($dupeTeacher, 'dupe_teacher', function ($join)
{
$join->on('load_schedule.day','=', 'dupe_Schedules.day');
$join->on('load_schedule.c_time','=', 'dupe_Schedules.time_from');
$join->on('load_schedule.c_time','=', 'dupe_Schedules.time_to');
})
->paginate(10);
I don't think you can do it as you're currently envisaging, as even if you could get it to see "M-W" as being a duplicate of either "M" or "W", it would not see it as a duplicate for "T". And two days of the week start with T...
You would be better, I think, storing the schedule entries in a separate table, using a relationship to tie it to a particular teacher. Each schedule entry would have a start time and an end time - when you populate it (however you populate it) if the schedule is for Monday 8:00 - 9:30 it just creates one entry in the schedule entries table. If the schedule is for Monday - Wednesday 8:00 - 9:30 then it creates three entries in the schedule entries table.
Ideally you would store these as datetime fields (ie. the actual date of the Monday / Tuesday / Wednesday in question, so a schedule entry for today would have a start time of 2021-12-08 08:00:00 and an end time of 2021-12 09:30:00 but if these are teachers, then it may be that it is "every Monday at 08:00:00" in which case your schedule entries table would have one column for the day of the week (as an integer, so 1 for Monday, 2 for Tuesday, etc.), one column for start time and one column for end time.
As it stands, you're going to be doing a lot of juggling to get it to work as you envisage - the above approach would simplify it considerably.

Get a Specific WeekDay date after a date

I am trying to implement a delivery process that occurs at specific days of week for each region. So, in a Region that delivers on Tuesdays and Thursdays I need to be able to get next eligible date based on the date the product will be available. So, if I will have it read on the 5th, O need to get the date for the next Tuesday or Thursday.
I started implementing it on Carbon, but I and creating a lot of loops through dates, testing dates and checking if its valid. something of getting product availability date and checking each day after it if its a monday Tuesday or Thursday ... etc ///I am sure, using Carbon, will have a better way to do it.
Any hint on how to do that ?
Thanks for any help!
Define a date:
$date = Carbon::now();
Now you have to get the day:
$day = $date->dayOfWeekIso
If $date is monday, then you will get a integer and that would be 1. That is because: 1 (monday), 2 (Tuesday), ..., 7 (sunday).
Now that you have this number you just need to apply some simple logic.
If the number you get is a 2 (Tuesday) then you will need to add two days to your $date in order to get the delivery date:
$delivery_date = $date->addDays(2);
If your day is equal 4 (Thursday), then you need to add 6 days to your $date so that would give you the next Tuesday:
$delivery_date = $date->addDays(6);
I think that's what you want! I hope it helps!

calculated return from entityrepository method

Was wondering if its possible (or maybe just not best practice) to return a calculated value from an EntityRepository method, or if I should be doing the calculation somewhere else. For example.
My Entity Users have Times (times are a Day of the week and a corresponding time for that day of the week not a hard date)
Looking to write a function that returns their NEXT time specific to the date, so for example if today is 2/8/16 (Monday) and the next "Time" is Tuesday at 12:00PM I want the function to simply return a DateTime object reflecting 2/9/16 12:00PM

Ruby/ice_cube: Exclude whole day for hourly recurring event

Just started playing around with ice_cube I've got a weekly schedule (with a granularity of half an hour) created
schedule = IceCube::Schedule.new(Time.now.change(:min => 30))
with several rules (let's say 20) such as e.g.
IceCube::Rule.weekly.day(:tuesday).hour_of_day(14).minute_of_hour(30)
or
IceCube::Rule.weekly.day(:wednesday).hour_of_day(10).minute_of_hour(0)
Now I'd like to exclude a full day, which would subsequently exclude all occurrences during this full day.
I've tried
schedule.add_exception_date [DATE]
but it seems that my exception has to match the event exactly.
Is there a way to get this done without looping through all rules and creating exception for the exact times for the date specified?
Update:
To make a better example:
Weekly schedule:
* Every monday at 14:40
* Every monday at 15:00
* Every thursday at 16:00
* Every saturday at 10:00
Exception date:
Tuesday, 13th of September 2011
=> For the week from Monday 12th to Sunday 18th I'd like to get only the occurrences on Thursday and Saturday.
One solution could look something like this, but it's a little icky:
schedule = IceCube::Schedule.from_yaml([PERSISTED SCHEDULE])
occurrences = schedule.occurrences_between([START TIME], [END TIME])
exceptions = schedule.exdates.map(&:to_date)
occurrences.reject {|occurrence|
exceptions.include?(occurrence.to_date)
}
—Any better ideas?
Since there seems to be no other solution and in order to close this question, here’s what I'm using (as described in an update to the original question above already):
schedule = IceCube::Schedule.from_yaml([PERSISTED SCHEDULE])
occurrences = schedule.occurrences_between([START TIME], [END TIME])
exceptions = schedule.exdates.map(&:to_date)
occurrences.reject {|occurrence|
exceptions.include?(occurrence.to_date)
}

Resources