DST issue with Codename one Calendar code - codenameone

Creating the object for Calendar and get the time and hour and minute from it.
It gives one hour less in iPad devices for Easter Time Zone (-5:00).
is this existing, does we need to consider any code changes on creating the Calendar Object.
Calendar now = Calendar.getInstance();
Dialog.show("Time value -- 1", now.getTime().toString(),"ok",null);
now.set(Calendar.YEAR, now.get(Calendar.YEAR));
now.set(Calendar.MONTH, now.get(Calendar.MONTH));
now.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH));
now.set(Calendar.HOUR_OF_DAY, now.get(Calendar.HOUR_OF_DAY));
now.set(Calendar.MINUTE, now.get(Calendar.MINUTE));
now.set(Calendar.DAY_OF_WEEK, now.get(Calendar.DAY_OF_WEEK));
Dialog.show("Time value -- 2", now.getTime().toString(),"ok",null);
Dialog.show("Time value -- 3", " "+now.getTimeZone(),"OK",null);
java.util.TimeZone timeZone = (java.util.TimeZone)now.getTimeZone();
Dialog.show("timeZone.useDaylightTime() -- ", timeZone.useDaylightTime()+" " ,"ok",null);
From the above code in iPad version 10.2 and for Time Zone New York, U.S.A we are getting useDaylightTime as false. whereas in simulator its value is true.
is there any way to handle DST issue on iPads in codename one.
due to calendar code, we are getting 1 hour less from actual time.
Thanks in advance.

There was a bug in the iOS VM that is now fixed. The fix should be available on the build server soon (within the next day or so). That will fix this issue.

Related

FLINK- Load historical data and maintain window of 30 days

My requirement is to hold 30 days data into stream to given any day for processing. so first day when FLINK application will start, it will fetch 30 days data from database and will merge to current stream data.
My challenge is - manage 30 days data window. If I create slidingwindow for 30 days with sliding time 1 day. something like
WatermarkStrategy<EventResponse> wmStrategy = WatermarkStrategy.<EventResponse>forBoundedOutOfOrderness(Duration.ofMillis(1))
.withTimestampAssigner((eventResponse, l) -> eventResponse.getLocalDateTime().toEpochSecond(ZoneOffset.MAX));
ds.assignTimestampsAndWatermarks(wmStrategy)
.windowAll(SlidingEventTimeWindows.of(Time.days(30), Time.days(1)))
.process(new ProcessAllWindowFunction<EventResponse, Object, TimeWindow>() {
#Override
public void process(Context context, Iterable<EventResponse> iterable, Collector<Object> collector) throws Exception {
--- proccessing logic
}
in this case process() do not start processing immediately when first element of historical data is added. my assumption is ```a) by default first event will be part of first window and will be available for processing immediately. b) next day job will remove last 29th day data from window. is my assumption correct with that piece of code? thank you for your help on this.
I don't think that Your assumptions are correct in this case. When You are using the TimeWindow with ProcessFunction it means that the function is able to process the data when the window is closed (in Your case after 30 days). In this case, slide in time window means that the second window will contain 29 days of the first window and 31st day which was not part of the first window.

Why isn't date sort working across browsers?

I am trying to implement a date-sorting method for a news list that works across browsers. However, the one method I have tried that works well, only works in Chrome:
origArt.sort(function(a, b) {
var dateA = new Date(a.date), dateB = new Date(b.date);
return dateB - dateA;
});
I also tried this code, suggested in other sorting questions as a possible solution:
origArt.sort(function(a,b){
return (b.date > a.date) ? 1 : (b.date < a.date) ? -1 : 0;
});
But, because the dates in my JSON vary from year; month & year; and month, year and day; the news list sorts in reverse
alphabetical order, not reverse chronological order.
They are strings such as: "2018.", "April 8, 2015.", and "September 2015."
Your problem is that those aren't valid date strings. From some quick testing, Chrome appears to be doing a bit of guesswork as to what you mean, but the other browsers aren't.
Chrome:
new Date("2018.")
// Mon Jan 01 2018 00:00:00 GMT-0800 (Pacific Standard Time)
Firefox:
new Date("2018.")
// Invalid Date
And since Invalid Date > Invalid Date is always false, it isn't sorting anything. It's not just a matter of removing the period either, since "September 2015" also works in Chrome but fails in Firefox.
Ideally, you should fix your JSON or whatever code it's being generated from to use parseable date strings. If that's not an option, you'll probably have to write a custom parsing function that handles all the possible formats you might get, or see if a library like Moment.js can handle it for you.

Calendar time zone DST issue Calendar on codename

We used following code to get the time
Calendar now = Calendar.getInstance();
int hour = now.get(Calendar.HOUR_OF_DAY);
int minute = now.get(Calendar.MINUTE);
int amPmVal = now.get(Calendar.AM_PM);
But when we change Timezone to New York in iPad it gives 1 hour less.
Can we handle this DST issue in codename one?
You set the hour but didn't set the date so DST might not be in effect. Also make sure DST is correctly set in the iPad itself and not just the hour.

Merge two first and second elements in ArrayBuffer

I have these ArrayBuffers:
ArrayBuffer(1.0, $, monitor, fine, couple, week, develop, expo)
ArrayBuffer(2.0, $, latest, company, follow, mercedes, unreliable, territory)
ArrayBuffer(5.0, $, plan, everyday, continually, surprised, fault)
ArrayBuffer(2.0, $, work, box, broken, turn, turn, seconds, very, frustrating)
ArrayBuffer(7.0, $, wait, deliver, wait, deliver, doesnt, bode, well, sony)
...
and i want to make below strings from these ArrayBuffers:
1.0$ monitor fine couple week develop expo
2.0$ latest company follow mercedes unreliable territory
5.0$ plan everyday continually surprised fault
2.0$ work box broken turn turn seconds very frustrating
7.0$ wait deliver wait deliver doesnt bode well sony
...
and i've tried:
val ArrBuf1 = ArrayBuffer.map(_.mkString(" "))
val out = ArrBuf1.filter(_.nonEmpty)
but my code shows these results:
1.0 $ monitor fine couple week develop expo
2.0 $ latest company follow mercedes unreliable territory
5.0 $ plan everyday continually surprised fault
...
How can i merge two first and second elements in these Arraybuffers?
Replace:
_.mkString(" ")
with:
l => l.head + l.tail.mkString(" ")
This will help you incase you need to merge any field of the collection
code:-
var x =List(ArrayBuffer(1.0, "$"," monitor"," fine"," couple"," week"," develop", "expo"),
ArrayBuffer(2.0, "$"," latest"," company"," follow"," mercedes"," unreliable"," territory"),
ArrayBuffer(5.0, "$"," plan"," everyday"," continually"," surprised"," fault"),
ArrayBuffer(2.0, "$"," work"," box"," broken"," turn"," turn"," seconds"," very"," frustrating"),
ArrayBuffer(7.0, "$"," wait"," deliver"," wait"," deliver"," doesnt"," bode"," well"," sony"))
var mergerAtFeild=1
x.foreach { x => x.zipWithIndex.foreach{
f=>{
print(if(f._2 == mergerAtFeild){f._1.toString()}else{" "+f._1.toString()})
}
}
print("\n")
}

Infragistics UltraCalendarCombo seems to be on drugs

I have an UltraCalendarCombo calendar control that I need to disable a set of dates in (weekends and public holidays basically).
I iterate through the list of dates for that month and set all the corresponding dates to disabled, this makes the current month look alright, but when I click the next month button on the control and try to access a month past now + 3 or 4 it jumps back to this month.
Has anyone any idea what this control is smoking, and where I can get some?
DateTimeCollection badDates = getMeSomeBadDatesmonth, year);
foreach (DateTime date in badDates)
{
myForm.CalendarInfo.DaysOfMonth[date.Day].Enabled = false;
}
Their controls have been going downhill for some time. I want to know what they are all smoking over there. I have been using their controls since the 2004 version of Net Advantage(which I really liked), but I have given up on using them on any new development. The bloat of features has broken what functionality did work and the documentation is just horrendous :(
Sorted it, the DaysOfMonth collection applies to a specific day (by number) of all months. For example, DaysOfMonth[10] applies to the tenth of every month of the year.
So I needed to use:
Infragistics.Win.UltraWinSchedule.Day theDay = _form.ValueDateCalInfo.GetDay(date, true);
if (theDay != null) theDay.Enabled = false;

Resources