The analog of java.util.Calendar in Ionic - ionic-framework

I need to do calculations like:
Given Unix time, tell the day of week.
Add given number of seconds to the known date, and get the new date.
Get the time (duration) difference between the two dates.
Ideally it should figure out for me the number of working days between the two Unix times but I understand that this may be too much.
When using Java, I would use java.util.Calendar for all these tasks. Which tools should be used in Ionic framework to get the same functionality? I tried to google "calendar ionic" but all results point to the Calendar GUI component that is not relevant for my task.

Related

iCalendar: How to exclude a time range from a RRULE?

I would like to exclude a time range from a RRULE.
For example the RRULE:
DTSTART;VALUE=DATE-TIME:20210104T142711Z
RRULE:FREQ=HOURLY;INTERVAL=2
will create a recurrent event every two hours, but I would like to exclude a period of time during the night, for example from 22:00 to 6:00.
I have read how to exclude dates using the EXDATE property, but I have not found information in the RFC about how to exclude a period of time. Is this documented somewhere or is there a recommended way of doing this?
I suggest try
RRULE:FREQ=DAILY;BYHOUR=6,8,10,12,14,16,18,20
and test in all the applications you expect to deal with this. Some calendar applications don't do FREQ=HOURLY. EG:Last I looked, google didn't do FREQ=HOURLY. I don't know about BYHOUR. Test whether the applications will do BYHOUR?
This https://icalendar.org/iCalendar-RFC-5545/3-3-10-recurrence-rule.html explains the limiting or expanding of the number of recurrences.
If those are not accepted by your intended receiving applications, then another approach may be to generate multiple VEVENTS for each hour, all using FREQ=DAILY.

UiPath Orchestrator Triggers - Cron Expression For specific day of month or next working day if not a working day

I've currently got this Cron expression that I'm using to trigger a process in UiPath Orchestrator:
0 0 15 21W * ? *
Runs on the closest working day to the 21st of each month at 3pm.
However I need it to run on the next working day at 3pm if the 21st is a non working day.
Tried searching for an answer and nothing quite fit the brief.
I used this website to build my expression (which is a great tool) but it only had an option for 'nearest day' and not next working day given a specific day of month: https://www.freeformatter.com/cron-expression-generator-quartz.html
As you don't need the nearest day, you can't use the functionality of Orchestrator cronjob. I would recommend creating a wrapper process as follows:
Create a new process, let's call it StartJobByCheckingDate
Now create a trigger that starts StartJobByCheckingDate each day at 3pm
So that process is now your manager of your desired process
Now we need to check if it is the 21th day
Here you have different ways to solve it
You could create a DataTable or even a file in the StartJobByCheckingDate process, that contains all the different days where your desired process should be fired (but this is very manual, you might not want to update this every year, so this might not be the smartest but the easiest solution)
The other idea is to check if the current day is the 21th day. If so check if it is Saturday/Sunday (non-working day).
If true: you could now create a empty dummy file somewhere that tracks that the 21th was a non-working day, and the next day you check that file existing, if it exists you check the current day to be a working day, and if so you delete the file again and start your desired process
If false: just start your desired process directly
I think 2. idea would be that best. Sure you have 365 jobs runs/year. But when you keep that helper process smart this will just be seconds.
Another idea instead of using the dummy file, would be to use Entities. Smarter but need some more time to get familiar with.
We have (had) the exact same issue. Since UiPath doesn't offer a feasible solution out of the box, we will work around the restriction using the following strategy: We trigger the actual job daily, considering a custom-built, static NonWorkingDay-list that will just suppress the execution of the robot every day we don't want it to run.
These steps are needed:
Get a list with of all known bank holidays, saturdays and sundays until 2053 or so...
Build a the static exclusion-list using a script that does something like this (pseudocode. I will update the answer once we have actually implemented the solution):
1. get all valid execution dates
loop through every 28th of the month until end of 2053
if the date is in the bankHolidayList then
loop until the next bankDay is found
add it to the list of valid ExecutionDates
else
add the date to the validExecutionDate-list
2. build exclusion-list
loop through every day until end of 2053
if the date is not in the validExecutionDate-list
add it to the exclusionDate-list
Format the csv accordingly and upload it to the orchestrator tenant as a NonWorkingDay-List
Update your trigger to run daily at your desired time, using the uploaded NonWorkDay-Calendar
While the accepted answer will surely work as well, we prefered to go with this approach because having a separate robot that does nothing but executing a UiPath trigger just doesn't seem right to me. With this approach we have no additional code that we potentially need to maintain.
In my oppinion not having a solution for this concern out of the box is a lack of feature that UiPath will (hopefully) fix until end of 2053 ;-)
Cheers
You can configure your trigger to launch oftener, then manage dates at init of your process, but you must set up a list of "holydays" or check in some way.
Also you can use the calendar option of orchestrator (+info)

Reading dates from a NetCDF file using Fortran

I have to use Fortran for some calculations using data from NetCDF files. And, depending on user selections, I need to select only one or some months from each year.
The dates in the NetCDF file are coded sometimes as "months since XXXX-XX-XX", other times as "days since XXXX-XX-XX", others as "hours since XXXX-XX-XX XX:XX", etc.
In addition, these have to be interpreted as belonging to a certain type of calendar, which can be Gregorian, Julian, proleptic Gregorian, 360-day, etc.
After many searches I have a plan to attack this problem, but want to ask the experts before.
My plan is as follows:
Use the UDUNITS package to convert the date information contained in the NetCDF file, to a Julian/Gregorian date. For this, I have to:
Bind the C code of UDUNITS to Fortran.
Convert the date obtained, to the desired calendar. For this, I think that I have to use a calendar package. Which would be a good choice?.
Do you agree with this?
I think I have found a good solution: the cdi libraries, developed by the Max-Plank Institute and distributed under the GNU GENERAL PUBLIC LICENSE Version 2.
It defines the following types of calendars: CALENDAR STANDARD, CALENDAR PROLEPTIC, CALENDAR 360DAYS, CALENDAR 365DAYS and CALENDAR 366DAYS.
This seems to be a very proven code, since it is used by cdo, a widely used tool that manages netcdf files.

passing timezone from client (GWT) to server (Joda Time)

I'm using GWT on the client (browser) and Joda Time on the server. I'd like to perform some DB lookups bounded by the day (i.e. 00:00:00 until 23:59:59) that a request comes in, with the time boundaries based on the user's (i.e. browser) timezone.
So I have the GWT code do a new java.util.Date() to get the time of the request, and send that to the server. Then I use Joda Time like so:
new DateTime(clientDate).toDateMidnight().toDateTime()
The trouble of course is that toDateMidnight(), in the absence of a specified TimeZone, will use the system's (i.e. the server's) TimeZone. I've been trying to find a simple way to pass the TimeZone from the browser to the server without much luck. In GWT I can get the GMT offset with:
DateTimeFormat.getFormat("Z").fmt(new Date())
which results in something like "-0400". But Joda Time's DateTimeZone.forID() wants strings formatted like "America/New_York", or an integer argument of hours and minutes. Of course I can parse "-0400" into -4 hours and 0 minutes, but I'm wondering if there is not a more straightforward way of doing this.
You could use java.util.Date's getTimezoneOffset() method. It's deprecated, but that's pretty usual for Date handling in GWT currently.
And AFAIR, you can specify something similar to "UTC+4" in Joda time.
Update: I looked it up, and it's "+04:00". Or use DateTimeZone.forOffsetHours() or even forOffsetMillis().
Gwittir (http://www.gwtsite.com) is a library for GWT that includes many cool utilities, like databinding, animation, reflection, and more. However, there are some other interesting goodies as well like the new Joda Time integration. If you have ever been frustrated by GWT’s lack of java.util.Calendar support, you’ll love this, as it makes it easy to do date manipulations in your applications.
otherwise, there are other ways to get timezone offset with + & -.
import java.util.TimeZone;
use: TimeZone.getDefault().getRawOffset()
this function will return the offset time in millisecond about your phone seeting. For Example, GMT-04:00 is equals to (-4)*60*60*1000 = -14400000.
After some operations to get the number which you want.
I have a similar but slightly different problem I think.
I actually need to store the clients timezone on the server, so that I can send out messages about dates stored in their calendar.
The dates are stored in UTC time in google app engine and of course I can store the current Timezone offset when creating the appointment. The problem comes when for instance I want to send out a summary email with a list of upcoming appointments in it. These appointments need to be offset with the correct Timezone adjustments for the client (Im happy to assume that they are still in the same timezone as when they created the appointment).
The real problem comes with Daylight Savings adjustments, so for instance I might have appointments stored for Saturday 30th October 2010 at 1pm (BST[GMT+60]) and Monday 1st November 2010 at 1pm (GMT).
So as you can imagine, I cant just use the current timezone offset (BST) as that would mean that the appointment on Monday 1st November would be listed as 2pm rather than 1pm (GMT+60)
It occurs to me that the best way to deal with this is just to store the timezone offset with each appointment individually, but I feel it would be much better to be able to determine the original timezone correctly in the first place, then just let java do the correct adjustments.

Is there a cocoa library for advanced date + time handling?

I need to do some date + time stuff that is not covered well by NSDate on the iPhone. I wonder if there is a library that has more sophisticated functionality regarding dates and time on a international level.
What I want to do is advanced date + time mathemathics. I need to:
convert between different calendar types (Gregorian <> Jewish <> Muslimish <> others)
convert times between different time zones (i.e. I have a swedish time and want to know what time is it in chicago)
add microseconds, seconds, minutes, hours, days, weeks, months, years to a date and find out what exact date+time it is then
find out how many microseconds, seconds, minutes, hours, days, weeks, months and years are between two given dates
draw calendars, so I need data about how many days a specific month has in a specific year
use case, for example: I fly from paris to chicago, and at 10:00 'clock in paris I only know the flight will take 10 hours. So I need to convert time zones and all this stuff to calculate what time I'll arrive in chicago. And then all this ugly summer and winter time stuff where they add or reduce one hour at some point in the year, and I think every country does that to their own liking, some may even fake the time way more than that adding a whole day to a year just to have more time. Don't know. Maybe there's a lib that protects me from all this complexity.
Basically what I want to do is a kind of world calendar but with some special features.
It's in the Date and time programming guide.
Convert from one calender to another
Convert between time zones
Calendrical calculations
etc...
NSCalendar + NSDateComponents?
However, like Peter Hosey said, it's hard to know without knowing what it is you want to do.
For people coming here looking for a lib, try Erica Saduns NSDate-Extensions. It doesn't cover everything you might want, but at least you won't have to do the basic stuff yourself.