Determine if a date is during DST

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Determine if a date is during DST

    Is there an easy way in coldfusion to determine if a give date/time
    happened/will happen during Daylight Saving Time? I can find out if the server
    is currently observing DST. But I need to know this for a time stamp that was
    recorded without time zone info. I know that the time zone this was recorded
    for does observer DST, but I don't want to have to write a function to parse
    out if the day falls between April and October.

    Any help? Or am I going to have to do this the hard way?


    Guest

  2. Similar Questions and Discussions

    1. JSObject returns wrong date. How can Iextract correct date from digital signature?
      I'm trying to extract name and date from digital signatures by using JSObject in Excel VBA, but JSObject returns wrong date. Year, month, hour and...
    2. #39245 [NEW]: date function generate wrong date with 1162083600 timestamp
      From: lohner at aldea dot hu Operating system: Linux PHP version: 5.1.6 PHP Bug Type: Date/time related Bug description: ...
    3. determine the clients date & time
      When someone submits a form I want to determine the _clients_ date and time. So I can't use now() since that gives me the date and time of the...
    4. Using ASP to determine the OS
      I want to determine the operating system using ASP (or VBScript inside of ASP). I tried to get it using the Request....
  3. #2

    Default Re: Determine if a date is during DST

    [url]http://www.sustainablegis.com/projects/tz/testTZCFC.cfm[/url] should do the trick.

    PaulH Guest

  4. #3

    Default Re: Determine if a date is during DST

    Ok, that is along the same line as what I am needing, but not quite. What I
    need is to determine if a date happend during daylight saving time. But that
    information is not stored in the data. Basicly what I need is an algorithm for
    calculating if a date falls between the begining and ending of DST. I tried
    using dateConvert(local2utc, date) as I know that the dates were recorded with
    DST taken into account. But that is giving the same UTC offset for every day
    of the year. (the server is in DST right now).


    Guest

  5. #4

    Default Re: Determine if a date is during DST

    Look in the Java API for Timezones at java.sun.com. There is a method that
    allows you to check and see if a date / time falls in daylight savings.

    An example of how to use that in Cold Fusion is the following:

    <cfobject type="java" class="java.util.TimeZone" name="TZ" action="create">
    <cfset tzdate = tzdatechk.init(#DateFormat(thedate, 'yyyy')#,
    #DateFormat(thedate, 'mm')#, #DateFormat(thedate, 'dd')#)>
    <cfif #ret.inDaylightTime(tzdate)# EQ true>
    **do stuff**
    </cfif>

    Hope this helps.

    Phil

    Another Phil Guest

  6. #5

    Default Re: Determine if a date is during DST

    Very cool, Phil, thanks!
    I'm not that familiar with using java objects in coldfusion code. But, I can
    see how they would be very powerful. (Personaly I'd rather by writting code in
    java than cfml anyway)

    Guest

  7. #6

    Default Re: Determine if a date is during DST

    if you looked at that CFC you should have seen a method isDST() to handle that.
    you pass it a valid cf datetime & a timezone ID & it would return whether or
    not that datetime is in DST or not. not all tz have DST (there are islands of
    non-DST tz in the US for example), not all tz start/end DST aty the same time.



    PaulH Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139