lundi 27 août 2018

filtering data in array

I have an array, of type myClass, got (status, description_1, description_2, .. till 6, duration_1 ... till 6, fromDay_1 to 6, toDay_1 to 6 fromTime_1 to 6 toTime_1 to 6) these data all in String format: data Example:

    "status" : "present",
    "description1": "2P MTR M-F 7:30-16:00",
    "description2": "2P MTR M-F 18:30-20:30",
    "description3": "2P MTR SAT 7:30-20:30",
    "description4": "2P SUN 7:30-18:30",
    "duration1": "120",
    "duration2": "120",
    "duration3": "120",
    "duration4": "120",
    "endtime1": "16:00:00",
    "endtime2": "20:30:00",
    "endtime3": "20:30:00",
    "endtime4": "18:30:00",
    "fromday1": "1",
    "fromday2": "1",
    "fromday3": "6",
    "fromday4": "0",
    "starttime1": "07:30:00",
    "starttime2": "18:30:00",
    "starttime3": "07:30:00",
    "starttime4": "07:30:00",
    "today1": "5",
    "today2": "5",
    "today3": "6",
    "today4": "0"

I have a 3000 data set. I need to output a different result for each set for example :

if (current time between fromTime_1 and toTime_1) and (current week day between fromDay_1 and toDay_1) output: description_1 else if (current time between fromTime_2 and toTime_2) and (current week day between fromDay_2 and toDay_2) output: description_2. and so on for all the 6 conditions.

The other part is I also wanted to display different img on the screen for below conditions:

if (current time between fromTime_1 and toTime_1) and (current week day between fromDay_1 and toDay_1) and status = Unoccupied "but i need to check if the status is = present" and duration_1 = 15 "but duration might be 60 or 120 or 240 and that is output a different img in regarding to the time and the status" output: imgGreen

else if ... same for all 6 conditions. What is the best way to filter my data, I have not much experience in this type of data filtering so please help. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire