Operating System - HP-UX
1755065 Members
3184 Online
108829 Solutions
New Discussion юеВ

URGENT HELP REQUIRED on DATE to add 1 or more days getting error date when BST to GMT time conversio

 
SOLVED
Go to solution
Satish Kumar Malisetti
Frequent Advisor

URGENT HELP REQUIRED on DATE to add 1 or more days getting error date when BST to GMT time conversio

Hello ALL,

I have a written a script ,
which converts currenr date into epoch seconds
and add number of days (ex: 1 ,2,3)
multilpy the days*86400 seconds
convert that seconds into date

every day i am adding 1 or 2 days depending on the requirement to the current date

but this is not adding one day when the time zone is from BST to GMT as 1 hour reduces

for that i have written only for that particular day if the passed date and coneverted date are same then add 25 hours for that particular day

but when i am passing days to add while converting from BST to GMT i am getting only one day is adding
15 REPLIES 15
Horia Chirculescu
Honored Contributor

Re: URGENT HELP REQUIRED on DATE to add 1 or more days getting error date when BST to GMT time conversio

Hello,
Please check on this thread:

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1411389

The perl script that James has posted. There is also an older thread listed there.

strftime just converts the seconds into a desired format.

Horia.
Best regards from Romania,
Horia.
Matti_Kurkela
Honored Contributor

Re: URGENT HELP REQUIRED on DATE to add 1 or more days getting error date when BST to GMT time conversio

So the date should be increased by N days, but the (local timezone) time should stay the same, right?

How about if you just do the calculation like you do now, but then overwrite the hour/minute/second part of the answer with the hour/minute/second of the original date?

MK

MK
Laurent Menase
Honored Contributor

Re: URGENT HELP REQUIRED on DATE to add 1 or more days getting error date when BST to GMT time conversio

Matti, may be there would be an error at dst change time...


Else if you share your script which makes that, and an example, it may be more easy to help you.
Satish Kumar Malisetti
Frequent Advisor

Re: URGENT HELP REQUIRED on DATE to add 1 or more days getting error date when BST to GMT time conversio

Laurent Menase ,


script and eaxmple given below

proc Lb_AddDaysToDateWithoutTime { pm_current_date pm_days }{


set lv_epochCurrentDate [mktime $pm_current_date ]
local lv_futureSec [expr $pm_days * 86400]
local lv_futureAdd [expr $lv_epochCurrentDate + $lv_futureSec]
local lv_futureConvert [date $lv_futureAdd]
return $lv_futureConvert
}

example :

dsd >puts [Lb_AddDaysToDateWithoutTime 20101031 1]
answer : 20101031

dsd >puts [Lb_AddDaysToDateWithoutTime 20101030 1]

answer : 20101031


Please look into above example, now the time zone is GMT0BST
same script is working fine when time zone is GMT




Laurent Menase
Honored Contributor
Solution

Re: URGENT HELP REQUIRED on DATE to add 1 or more days getting error date when BST to GMT time conversio

It is because of 20101031 is the dst change date, so the day last 1 hour more,

Since you calculate the date at 0:0:0 when you add 86400sec, you will be on the same day at 11pm

So workarounds: make the calculation at midday (12:00:00)
Laurent Menase
Honored Contributor

Re: URGENT HELP REQUIRED on DATE to add 1 or more days getting error date when BST to GMT time conversio

other workaround, add 43200 to the date

local lv_futureSec [expr $pm_days * 86400 + 43200]


Satish Kumar Malisetti
Frequent Advisor

Re: URGENT HELP REQUIRED on DATE to add 1 or more days getting error date when BST to GMT time conversio

thanks alot it working fine

but i need to check with the design team whether we can take midday timeor not
Laurent Menase
Honored Contributor

Re: URGENT HELP REQUIRED on DATE to add 1 or more days getting error date when BST to GMT time conversio

+ 43200 is changing exactly the time to midday :D
Dennis Handly
Acclaimed Contributor

Re: URGENT HELP REQUIRED on DATE to add 1 or more days getting error date when BST to GMT time conversio

If this uses the C mktime(3) then there is a tm_isdst field that indicates if DST is in effect. If this value changes from the start to the end date, you know you have to adjust your hour and possibly minute fields.