why timezone conversion gives me a minute difference when user on different timezone?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 11:41 PM - edited 05-08-2024 02:31 AM
script used :
Hi,
please find me a solution for the below query.
var ga = gs.getSession().getTimeZone();
gs.info('userTimezone'+ga);
var cor = new GlideRecord('x_novrp_it_it_change');
cor.addQuery('sys_id', '96fa52c98786461049aa0d030cbb359c');
cor.query();
if (cor.next()) {
var startdateofchgci = cor.start_date;
var enddataeofchgci = cor.end_date;
gs.info('startdateofchgci'+startdateofchgci);
gs.info('enddataeofchgci'+enddataeofchgci);
}
var scheduleEntryGRsoft = new GlideRecord('cmn_schedule_span');
scheduleEntryGRsoft.addQuery('schedule', 'b257e7a11b398e5884e2caa16b4bcb62');
scheduleEntryGRsoft.query();
if (scheduleEntryGRsoft.next()) {
var schedulesysid = scheduleEntryGRsoft.schedule;
var recurrencerule = scheduleEntryGRsoft.schedule;
var schedule = new GlideSchedule(recurrencerule);
schedule.setTimeZone('Europe/Dublin');
var gdt_start = new GlideDateTime(startdateofchgci);
var gdt_end = new GlideDateTime(enddataeofchgci);
var dur = schedule.duration(gdt_start, gdt_end);
var schedule_time = dur.getNumericValue() / 1000;
if ((schedule.isInSchedule(gdt_start)) || (schedule.isInSchedule(gdt_end)) || (schedule_time > 0)) {
gs.info('FOUND IN SCHEDULES:');
}else{
gs.info('NOT FOUND IN SCHEDULES:');
}
}
NOTE: My system timezone is europe/Dublin
1. checking my planned start and planned end coincides with the black out schedule?
user is in Europe/Dublin - (Working fine)
OUTPUT 1: checking my planned start and planned end coincides with the black out schedule?
user is in EuropeDublin - (Working fine)
*** Script: userTimezonesun.util.calendar.ZoneInfo[id="Europe/Dublin",offset=0,dstSavings=3600000,useDaylight=true,transitions=227,lastRule=java.util.SimpleTimeZone[id=Europe/Dublin,offset=0,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
*** Script: startdateofchgci 2024-06-01 15:00:00
*** Script: enddataeofchgci 2024-06-01 16:00:00
*** Script: FOUND IN SCHEDULES:
2. checking my planned start and planned end coincides with the black out schedule?
USER is in IST timezone ( not Working fine) , eventhough using the same script
OUTPUT 2:
*** Script: userTimezonesun.util.calendar.ZoneInfo[id="IST",offset=19800000,dstSavings=0,useDaylight=false,transitions=7,lastRule=null]
*** Script: startdateofchgci 2024-06-01 15:00:00
*** Script: enddataeofchgci 2024-06-01 16:00:00
*** Script: NOT FOUND IN SCHEDULES:
3. checking my planned start and planned end coincides with the black out schedule?
USER is in IST timezone ( Working fine) , just reduce a minute from my planned start date for testing
OUTPUT 3:
*** Script: userTimezonesun.util.calendar.ZoneInfo[id="IST",offset=19800000,dstSavings=0,useDaylight=false,transitions=7,lastRule=null]
*** Script: startdateofchgci2024-06-01 14:59:00
*** Script: enddataeofchgci2024-06-01 16:00:00
*** Script: FOUND IN SCHEDULES:
Schedule dates:
start date time - 01/06/2024 14:00:00
end date time - 01/06/2024 16:00:00
the script is same
the change request date which i pass are same even when changing the user timezone
iam passing only GMT value of start and end dates so it will be same always
but why different outputs?
with 1 minute difference it is now working as expected why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 11:55 PM
You are just giving queries. What is your question? What isn't working? What's the goal of the scripts? What's the expected outcome and what is the actual outcome?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 12:44 AM
What is your question?
Iam trying to check whether my change request planned start and planned dates fall inside the my blackout out schedule window
What isn't working?
Same script not working for other time zones and providing a minute difference
the script is same the change request date which i pass are same even when changing the user timezone iam passing only GMT value of start and end dates so it will be same always but why different outputs? with 1 minute difference it is now working as expected why?
What's the goal of the scripts?
To check the change request falls in blackout window or not
What's the expected outcome and what is the actual outcome?
expected outcome - In IST time zone also the system should find my change is present in the BW schedule.
actual outcome - with a minute of difference only Iam able to achieve it but without even a minute difference i need the system tom find it is in blackout schedule as same as OUTPUT 1
@Mark Manders
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 12:44 AM
What is your question?
Iam trying to check whether my change request planned start and planned dates fall inside the my blackout out schedule window
What isn't working?
Same script not working for other time zones and providing a minute difference
the script is same the change request date which i pass in GMT are same even when changing the user timezone iam passing only GMT value of start and end dates of change request so it will be same always but why different outputs?
why a minute difference for other timezones - it is now working as expected
What's the goal of the scripts?
To check the change request falls in blackout window or not
What's the expected outcome and what is the actual outcome?
expected outcome - In IST time zone also the system should find my change is present in the BW schedule.
actual outcome - with a minute of difference only Iam able to achieve it but without even a minute difference i need the system tom find it is in blackout schedule as same as OUTPUT 1
@Mark Manders