Author Topic: Daylight Savings Time  (Read 59 times)

chrislegarth

  • Newbie
  • *
  • Posts: 33
Daylight Savings Time
« on: November 28, 2018, 09:01:03 am »
I wrote a program that is use to check AD accounts of new hire employees to verify that the accounts is in an "OK" state whey they show up for orientation.
One of the checks is to determine if the original password has been changed.  What I am doing to verify this was to "hardcode" the date/time in the comments property of the AD account.  I would then compare that time (ESS Pwd. Set column) with the pwdlastset time (Pwd. Changed column).  If the times are off by more than a few seconds, I assume the password was changed from the original.  DST seems to had wrecked havoc on that comparison.  The script that creates accounts runs daily at 6:15AM local time (ET).  When comparing these times during DST, the comparison works.  Now that DST ended, the times are off by 1 hour.  Will the times be off again in March when the DST begins again?  What is the best way to accomplish what I am trying to do?  Should I store my "hardcoded" time as UTC and then calculate that against locate time?  See the screenshot to illustrate what is happening.

Any advice is appreciated and Thanks!

Why do we still change our clocks!?!?

ChuckC

  • Full Member
  • ***
  • Posts: 165
Re: Daylight Savings Time
« Reply #1 on: November 28, 2018, 09:35:05 am »
Never store localized time stamp values.  Always store them as UTC/GMT values when you need to compare them again in the future.

As a work around, if you know the time zone and the time zone's DST rules for any given local time, could properly convert the localized time back to a UTC/GMT value.

td

  • Tech Support
  • *****
  • Posts: 2653
    • WinBatch
Re: Daylight Savings Time
« Reply #2 on: November 28, 2018, 09:51:03 am »
I guess the first solution would be to have a password expiry policy so users are automagically forced to change them.  If that is not an option, you will need to convert either to or from UTC ( as Chuck indicated preferably too UTC.)  Assuming that you plan on are using WinBatch in some fashion to resolve the problem, there are several recent posts on this forum that have examples of doing exactly that. 

As to why Daylight Saving Time is still around I couldn't say.  Maybe it still exists to give contentious people another thing to debate about in their spare time.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


chrislegarth

  • Newbie
  • *
  • Posts: 33
Re: Daylight Savings Time
« Reply #3 on: November 28, 2018, 12:24:56 pm »
Thanks for the advice as always.  I have converted all my time stamps to UTC and convert them back to local time when comparing them.
All's good in my WinBatch world again.

We can thank New Zealand entomologist George Hudson and English builder and outdoorsman William Willett for proposing DST to the world!

snowsnowsnow

  • Sr. Member
  • ****
  • Posts: 251
Re: Daylight Savings Time
« Reply #4 on: November 28, 2018, 03:10:51 pm »
The really funny thing about DST is that most of the proposals I've seen for eliminating the clock changing ritual are in the form of "year around daylight saving time".  I.e., never standard time.

Which is obviously whack on its face...

Russell_Williams

  • Newbie
  • *
  • Posts: 11
Re: Daylight Savings Time
« Reply #5 on: November 29, 2018, 06:27:23 am »
When told the reason for Daylight Saving Time, the Old Indian said,
"Only the government would believe that you can cut a foot off the top
of a blanket, sew it to the bottom, and get a longer blanket."