Daylight Savings?
[1/4] from: ryan::christiansen::intellisol::com at: 18-Jun-2001 10:11
I worked up a function for finding out whether or not you are in Daylight
Savings time in the United States.
Ryan C. Christiansen
Web Developer
Intellisol International
4733 Amber Valley Parkway
Fargo, ND 58104
701-235-3390 ext. 6671
FAX: 701-235-9940
http://www.intellisol.com
Global Leader in People Performance Software
_____________________________________
Confidentiality Notice
This message may contain privileged and confidential information. If you
think, for any reason, that this message may have been addressed to you in
error, you must not disseminate, copy or take any action in reliance on it,
and we would ask you to notify us immediately by return email to
[ryan--christiansen--intellisol--com]
[2/4] from: ryan:christiansen:intellisol at: 18-Jun-2001 10:20
Daylight Savings function
If you are in the United States in a location where Daylight Savings Time
is observed, here is a function to figure out whether or not you are in
Daylight Savings Time.
U.S._DaylightSavings?: func [
/local FirstSundayOfApril LastSundayOfOctober GMT GMT-based_U.S.
_DaylightSavingsBeginDate_CurrentYear GMT-based_U.S.
_DaylightSavingsEndDate_CurrentYear
][
FirstSundayOfApril: func [
year
][
make-begin-date: rejoin [{1-Apr-} year]
begin-date: make date! (make-begin-date)
either begin-date/weekday = 7 [
begin-date
][
until [
begin-date: begin-date + 1
begin-date/weekday = 7
]
begin-date
]
]
LastSundayOfOctober: func [
year
][
make-begin-date: rejoin [{31-Oct-} year]
begin-date: make date! (make-begin-date)
either begin-date/weekday = 7 [
begin-date
][
until [
begin-date: begin-date - 1
begin-date/weekday = 7
]
begin-date
]
]
GMT: now - now/zone
GMT-based_U.S._DaylightSavingsBeginDate_CurrentYear: FirstSundayOfApril
now/year
GMT-based_U.S._DaylightSavingsBeginDate_CurrentYear/time: 8:00:00
GMT-based_U.S._DaylightSavingsEndDate_CurrentYear: LastSundayOfOctober
now/year
GMT-based_U.S._DaylightSavingsEndDate_CurrentYear/time: 8:00:00
either all [(GMT > GMT-based_U.S.
_DaylightSavingsBeginDate_CurrentYear) (GMT < GMT-based_U.S.
_DaylightSavingsEndDate_CurrentYear)][
true
][
false
]
]
Ryan C. Christiansen
Web Developer
Intellisol International
4733 Amber Valley Parkway
Fargo, ND 58104
701-235-3390 ext. 6671
FAX: 701-235-9940
http://www.intellisol.com
Global Leader in People Performance Software
_____________________________________
Confidentiality Notice
This message may contain privileged and confidential information. If you
think, for any reason, that this message may have been addressed to you in
error, you must not disseminate, copy or take any action in reliance on it,
and we would ask you to notify us immediately by return email to
[ryan--christiansen--intellisol--com]
[3/4] from: jelinem1::nationwide::com at: 18-Jun-2001 14:39
I don't think I've ever made variable names (ie word names) that long
before.
Watch those line wraps!
<tucks the Daylight Savings function away in his folder of REBOL
tool-scripts>
- Michael Jelinek
[4/4] from: dness:home at: 19-Jun-2001 13:10
[ryan--christiansen--intellisol--com] wrote:
> If you are in the United States in a location where Daylight Savings Time
> is observed, here is a function to figure out whether or not you are in
> Daylight Savings Time.
>
...
Complex as it is, your function is a wild over-simplification of the `real'
situation wrt DaylightSavings in the US. It may work well enough for most
people's purposes, but it should be recognized that the real situation is
quite `political' in nature, and that your code will produce the wrong
answers for some places at some times...