GMT offset -- how to determine in RM?

How do I set a string variable to the current Hubitat GMT offset? I'm trying to build up a Time String in a rule.

Or do I actually need the GMT Offset? I'm only really interested in the time, not date or GMT offset per se. So could I build up a string representing 6:00pm in this format, with the "9" values meaning "don't care":

9999-99-99T18:00:00.000-9999

Could be a good use of the hard work of @jshimota in:

1 Like

Thank you! I did find that solution (which works perfectly for my purpose) in the wee hours this morning after my post.

I was hoping that there was a native Hubitat function in Rule Manager that would do the same (concerns about future maintenance of the Date Time Parser driver and all that). In the meantime, I'm going to try a test in which I set the GMT offset in the Time String to all 9's.

My testing shows that setting the GMT offset in a time string to "-9999" or "99999" fails.

morning - I offer it could be 2 possibilities - instead of offset, use a different timezone?

999 is a sort of filter pattern so to speak - using SDF (SimpleDateFormat as I recall).
If you look at my driver there are a myriad of pattern leads:

def runCmd() {
    now = new Date()

    // pattern definitions
    dTDayNamePattern = new SimpleDateFormat('EEEE')
    dTDayNameText3Pattern = new SimpleDateFormat('EEE')
    dTDayOfMonNumPattern = new SimpleDateFormat('dd')
    dTDayOfMonNumNoLeadPattern = new SimpleDateFormat('d')
    dTDayOfWeekNumPattern = new SimpleDateFormat('u')
    dTDayOfYearNumPattern = new SimpleDateFormat('D')
    dTDaysInMonthNumPattern = new SimpleDateFormat('MMMM')
    dTMonthNamePattern = new SimpleDateFormat('MMMM')
    dTMonthNameText3Pattern = new SimpleDateFormat('MMM')
    dTMonthNumPattern = new SimpleDateFormat('MM')
    dTMonthNumNoLeadPattern = new SimpleDateFormat('M')
    dTYearNum4DigPattern = new SimpleDateFormat('yyyy')
    dTYearNum2DigPattern = new SimpleDateFormat('yy')
    dTTimeHour12NumPattern = new SimpleDateFormat('hh')
    dTTimeHour24NumPattern = new SimpleDateFormat('HH')
    dTTimeHour12NumNoLeadPattern = new SimpleDateFormat('h')
    dTTimeHour24NumNoLeadPattern = new SimpleDateFormat('H')
    dTTimeMinNumNoLeadPattern = new SimpleDateFormat('m')
    dTTimeMinNumPattern = new SimpleDateFormat('mm')
    dTTZIDPattern = new SimpleDateFormat('zzzz')
    dTTZIDText3Pattern = new SimpleDateFormat('z')
    dTGMTDiffHoursPattern = new SimpleDateFormat('Z')
    dTTimeAntePostUpperPattern = new SimpleDateFormat('a')
    dTTimeAntePostLowerPattern = new SimpleDateFormat('a') //drop to lower case using temp value
    dTWeekOfMonNumPattern = new SimpleDateFormat('W')
    dTWeekOfYearNumPattern = new SimpleDateFormat('w')

Your driver worked perfectly -- I use it to set a hub variable, htGMT_Offset, that I use in 34 of my dimmer rules.

My comment above about "setting the GMT offset in a time string to "-9999" or "99999" fails" related to the inability of the native Hubitat Time String to allow 9's to filter/mask the GMT offset, even though 9's are allowed for filtering other portions of a Time String. So 9999-99-99T18:00:00.000-0800 works to filter the date portion (leaving 6:00pm), but 9999-99-99T18:00:00.000-9999 fails to filter the date and GMT offset portions.

2 Likes