zephyr/scripts/timestamp
Javier B Perez Hernandez f7fffae8aa Change BSD-3 licenses to Apache 2
Change all the Intel and Wind River code license from BSD-3 to Apache 2.

Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:29 -05:00

86 lines
2 KiB
Bash
Executable file

#!/bin/bash
#
# Copyright (c) 2015 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
exe_name=$(basename $0)
# outputs the date and time in pre-set formats
# default format is: 20150114-181112
# usage: timestamp [-a] [-d] [-u] [-s] [-S]
# where: -a changes default to: 2015-01-14-18-11-56
# -d changes default to: 20150114
# -u changes default to: 20150114_181201
# -s changes default to: 20150114-1812.04
# -S changes default to: 20150114-1812
# Some switches can be mixed and matched, eg. -Sa gives 2015-01-14-18-13
date_format="%Y%m%d"
time_format="%H%M"
seconds_format="%S"
seconds_separator=""
date_time_separator="-"
function usage {
printf "usage: %s [-a] [-d] [-u] [-s] [-S]\n" $exe_name >&2
}
function fail {
usage
exit -1
}
function get_opts {
declare -r optstr="adusSh"
while getopts ${optstr} opt; do
case ${opt} in
a) all_separated=1 ;;
d) date_only=1 ;;
u) date_time_separator="_" ;;
s) seconds_separator="." ;;
S) no_seconds=1 ;;
h) usage; exit 0 ;;
*) fail ;;
esac
done
}
get_opts $@
if [ x${all_separated} == x1 ]; then
date_format="%Y-%m-%d"
time_format="%H-%M"
seconds_separator="-"
fi
if [ x${date_only} == x1 ]; then
date_time_separator=""
time_format=""
seconds_format=""
seconds_separator=""
fi
if [ x${no_seconds} == x1 ]; then
seconds_format=""
seconds_separator=""
fi
output_date=${date_format}${date_time_separator}
output_time=${time_format}${seconds_separator}${seconds_format}
output=$(date +${output_date}${output_time})
echo ${output}