Business Working Hours based Due Date using joda - calendar

Does Joda support methods to arrive at due date based on working hours
I was able to use
- the holiday calendar
- configurable working days
to arrive at the due date
However, are there methods in joda to set the working hours as 8AM - 5PM and then calculate the due date ?
Sample scenario:
Time taken to complete a task: 10Hrs
Business working hours: 8AM - 4PM (8 Hrs)
Start Date of Task: 21-NOV-2016 ; 9AM
Expected Due Date of Task: 22-NOV-2016 ; 11AM
(i.e 7hrs of work completed on 21st and 3hrs of work completed on following working day which starts at 8AM)

No. From the Joda-Time documentation:
Joda-Time provides a quality replacement for the Java date and time
classes.
It is not within scope to deal with working hours and scheduling.

Related

Google cloud cron.yaml schedule formatting for custom repetitive interval

I'm struggling to format a cron schedule for gcp properly and the docs aren't really helping me out.
Cron #1: Run every 50 minutes from 11:00 to 21:00 only on the months from march to october inclusive
schedule: every 50 minutes from 11:00 to 21:00 of mar,apr,may,jun,jul,aug,sep,oct
Cron #2: Run every day at 22:00 only on the months from march to october inclusive
schedule: every day 22:00 of mar,apr,may,jun,jul,aug,sep,oct
Neither of those work, but they were one of my attempts. What am I doing wrong here?
Referring to the Formatting the schedule docs below.
There is no supported syntax for your 1st cron:
specifying minutes in an [INTERVAL_VALUE] is only supported by END-TIME INTERVAL and START-TIME INTERVAL formats, but neither of them allows specifying months in the [INTERVAL_SCOPE].
the only format supporting month specification in [INTERVAL_SCOPE] is CUSTOM INTERVAL, but that only supports day specifications in [INTERVAL_VALUE].
But you can achieve an equivalent functionality by using the finer time specification in cron.yaml and making a check for the remaining conditions inside the cron job itself, doing nothing if the condition is not met. So your 1st cron would be achieved with:
this cron.yaml entry:
schedule: every 50 minutes from 11:00 to 21:00
an additional check for the current month inside the cron job itself, doing nothing (just returning) if the month is Jan, Feb, Nov or Dec.
Your 2nd cron is possible using a CUSTOM INTERVAL, you just need to place the hour at the end of the [INTERVAL_SCOPE]. From the doc:
[INTERVAL_SCOPE]: Specifies a clause that corresponds with the
specified [INTERVAL_VALUE]. Custom intervals can include the of
[MONTH] clause, which specifies a single month in a year, or a
comma-separated list of multiple months. You must also define a
specific time for when you want the job to run, for example: of
[MONTH] [HH:MM].
So your entry would be:
schedule: every day of mar,apr,may,jun,jul,aug,sep,oct 22:00

How to get first of week based calendar in nodatime?

I want to get first day of week for specificid ZonedDateTime in NodaTime.
But week starts Saturday in Persian calendar and Monday in Gregorian calendar.
How can I get first day of week based on calendar of ZonedDateTime?
We don't expose that information, because it's not as cut and dried as you expect it to be. Different cultures and contexts use different week rules - for example, while you've stated that the week starts on Monday in the Gregorian calendar, that's context specific. In many contexts Sunday is used as the first day of the week instead.
See the week numbering part of the Wikipedia article on weeks for examples of this.
It sounds like you'll probably want a Dictionary<CalendarSystem, IsoDayOfWeek> or possibly a Dictionary<CalendarSystem, IWeekYearRule> in your application, depending on what you're trying to achieve.

Why are repeated days incorrect with this RRULE?

This should be a 2 hour 50 minute event starting at 5pm PST on a thursday evening repeating weekly. When imported into google calendar or Evolution, the first occurrence is correct, but subsequent weeks have the event on Wednesdays.
DTSTART:20170908T000000Z
DTEND:20170908T025000Z
RRULE:FREQ=WEEKLY;UNTIL=20171201T080000Z;BYDAY=TH
Other events that my application generate occur on multiple days i.e. BYDAY=TH,TU so simply removing the BYDAY is not a solution for my problem.
You are mixing up the timezone of the event and the display timezone. As far as recurrence calculation goes, the only thing that counts is the timezone that you declare in the VEVENT. Here you are using UTC. So:
The first instance is on the 20170908 which is a Friday. From there, you ask for a recurrence every thursday. The next thursday after 20170908 is 20170914, so the next instance starts on 20170914T000000Z.
When viewed with a display timezone of PST, this event has indeed its first instance on Thursday evening. But the second instance, as calculated above, is on a Thursday UTC time, so on a Wednesday PST time.
Besides this particular issue, you also need to worry about daylight saving changes. If your event is really taking place in PST timezone, the event, as expressed above will see its time change in November, after the DST transition takes place.
Hence it is almost never a good idea to express a recurring event by using UTC (Zulu) time.
You should have your event expressed in local time with timezone, i.e. use:
DTSTART;TZID="America/Los_Angeles":20170907T170000

Angular - Use of i18n and l10n for date time and timezone management

On server side DateTime is saved as per UTC (2016-03-24 17:45:12) and to client it is always returned DateTime as UTC. There are different users from world.
What is the best way to do date-time display management with i18n and l10n in angular?
Also i want that it should display date-time as per timezone of the user.
There are lots of feeds shown from all over the world like StackOverflow Posts. From server side always DateTime are passed in UTC time zone. On client side, date time can be displayed in two formats like below.
Showing date time of post as per time zone
Showing time-ago facility like (Just Now, Minute Ago, Hour Ago, Day Ago, Month Ago, Year Ago, 2 Years ago, 3 Years ago, etc)
This type of date times displayed across system multiple times for posts. So what is best way to use angular to have very less code for managing this.
How/When/Why to use Filters, Directives, Expressions for this?
(P.S. I am new to angular.)
Update:
More explanation:
Post object can be single page or array of objects.
And post date time will be like UTC: (2016-03-24 17:45:12)
So there are two cases which can be displayed like:
5 Months Ago
2016-03-24 11:15 PM (IST time)
You can trust the users' browsers. To display a date, you can use myDate.toLocaleString(). It will display the date using user's locale settings.
For "time-ago" format, you can use AngularJS version of moment.js: https://github.com/urish/angular-moment#am-time-ago-directive

Need design ideas: Searchable time/datetime for C# and SQL Server

I am trying to add a feature on one of my applications. Here is a sample:
Company ABC
Business hours:
Sunday closed
Monday 7am - 5pm
Tuesday 7am - 5pm
Wednesday 7am - 5pm
Thursday 7am - 5pm
Friday 7am - 5pm
Saturday closed
Company DEF
Sunday 10am - 12pm
Monday 8am - 4pm
Tuesday 8am - 4pm
Wednesday 8am - 4pm
Thursday 8am - 4pm
Friday 8am - 4pm
Saturday closed
Now, what I want to do is to have my users be able to search/filter the business hours. For example, only return businesses who are open during Monday 2PM, or Saturday 1PM, or Monday any time.
My idea is to use datetime in SQL Server, but it appears I may need to create 7 columns for each day (Sunday to Saturday) and different columns for Starting time to open to Closing time to open.
The next idea is to make these columns searchable such that I will be able to filter them. for example, if a user searches for Monday 12PM, the search will be Monday (open time) <= (user search, 12pm) <= (close time).
So basically, it will be similar to:
SELECT *
FROM Companies
WHERE [user_search_time] IS "BETWEEN open_time AND close_time WHERE day=[user_search_day]
I'm having a hard time designing this, let alone how to implement it.
Technology used is C#/ASP.Net and SQL Server 2008.
The problem is how to design/implement this feature using the technologies mentioned above.
Any idea/tips will be appreciated. Thanks!
Might want to push this to codereview, or programmers. I think you are on the right path, but instead of adding columns, add a new table. called business_hours
BUSINESS_HOURS
business (company fk)
open_time (datetime)
close_time (datetime)
day (M,T,W,TH,F,S,Sun) // you can do this however u want 1-7 would work as well
Then your query is almost the same as what you have.
SELECT *
FROM
business_hours
WHERE
business = user_company_id
[user_search_time] IS BETWEEN open_time AND close_time and
day=[user_search_day]
Benefits to a table is it's more denormalized and you could support hours that have breaks in them. I could suport 12-2 as well as 5-8. You would just insert a new record and it would work. I am not a big fan of doing all day by doing a range from 12AM to 12PM but it will work, and keep your design simple.

Resources