Detect DST from a date entered by user in bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Detect DST from a date entered by user in bash
# 1  
Old 12-17-2015
Detect DST from a date entered by user in bash

I am trying to write a bash script that takes in a users input of a specific date in a format such as MM/DD/YYYY and returns whether or not that specific date was during daylight savings time or not. Is there a specific function that checks this? Does the date command have a way to do this? I am using RHEL 6.4.
# 2  
Old 12-17-2015
I don't have access to a Linux system (so the following is untested), but the following should give you the Timezone string that applies to midnight at the start of the given date:
Code:
test_date="12/25/2000" # Format is "MM/DD/YYYY"
date -d"$test_date" +%Z

Note that on dates when there is a switch to or from daylight savings time, the answer for those two days each year (in areas where daylight savings time is observed) is not a constant for the entire day. That is why it is important to specify a specific time for the test rather than assume that the answer applies to the entire day.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Noob question: How to check the total number of inputs entered by user?

Say I have this line: read -p "Enter 3 numbers: " num1 num2 num3; I want to write a while loop that repeatedly asks for input if the number of inputs entered is not equal to 3. I don't know the correct command to find the number of inputs entered. Help, please? (4 Replies)
Discussion started by: jejemonx
4 Replies

2. Shell Programming and Scripting

How to check user entered correct file format or not?

Hi Experts, path=/db/files/ format=$1 User can enter any file format.compare the user file format with actual file format existed in the directory /db/files. User enter all characters as "A" apart from date format. example1: user will be entering the file format AAA_AA_YYYYMMDD.AAA Actual... (6 Replies)
Discussion started by: nalu
6 Replies

3. AIX

Need to get the next day's date of the user entered date

I need to get the next day's date of the user entered date for example: Enter date (yyyy/mm/yy): 2013/10/08I need to get the next day's date of the user entered date Desired Output: 2013/10/09Though there are ways to achieve this is Linux or Unix environment (date command) ,I need to... (1 Reply)
Discussion started by: rpm120
1 Replies

4. Shell Programming and Scripting

To get the files in a directory for the given date (User entered date)

Need a ksh script to get the files that were created or modified in a directory on a particular date entered by the user. For example if a directory contains files as below : > ll total 41 -rw-rw-r-- 1 psn psn 199 Aug 23 07:06 psn_roll.sh -rw-rw-r-- 1 psn psn ... (10 Replies)
Discussion started by: ramprabhum
10 Replies

5. Shell Programming and Scripting

Perl : accept multiple user entered command line arguemnts

I am trying to create a script that will accept multi input from the user (really just me), then execute those command on a remote device. My question is if the I enter "No" at the confirmation point "Are these statements correct y or n ?", what is the best way to go back and start over ? I... (3 Replies)
Discussion started by: popeye
3 Replies

6. Shell Programming and Scripting

Bash script to detect nonpingable hosts

I have a script to detect if a host is pingable or not. The problem is that I would like it to put the nonpingable hosts in one file and the pingable hosts in another. I have come up with this so far: for ip in `cat /tmp/testlist2`; do ping -c 3 $ip >/dev/null && echo "$ip is up" || echo "$ip... (5 Replies)
Discussion started by: newbie2010
5 Replies

7. Shell Programming and Scripting

find files for next day of the date entered

i have few files generated everyday with a date stamp. Sometimes it happens that if the files are generated late i.e after 00:00 hrs the date stamp will be of the next day. example: 110123_file1 110123_file2 110123_file3 110124_file4 in the above example file4 is also for the previous... (2 Replies)
Discussion started by: gpk_newbie
2 Replies

8. Shell Programming and Scripting

Detect ints and change to a Date format

Hello, I have been trying to figure out how to solve this problem and I have run into a dead end. I am trying to parse a text file that gives me a date and I need to read it into SQL server 2005 but SQL can't figure out its a time unless I put it in a different format. This is how my text file... (3 Replies)
Discussion started by: AlexDr
3 Replies

9. Shell Programming and Scripting

Determine if given date is in DST

Is there a way to figure out if given date is in DST or in EST? So imagine a shell script is_date_dst.sh sh is_date_dst.sh 2009-03-02 would return 0 and sh is_date_dst.sh 2009-03-22 would return 1 This script should not assume the timezone of the machine it runs on, but only the date passed... (7 Replies)
Discussion started by: asriva
7 Replies

10. Shell Programming and Scripting

validating user entered date

I need the date validation. I searched in the google but i didn't find my requirements. requirements: 1) user has to enter the date in YYYY/MM/DD format 2) MM validations 3) DD validations. and if the month is april it should allow 30 days only and for May month it should allow 31 days like... (1 Reply)
Discussion started by: KiranKumarKarre
1 Replies
Login or Register to Ask a Question