summaryrefslogtreecommitdiff
path: root/func/deriveTimeString.sh
blob: a09a393522281faac1320653db61f5b94ee1d9d5 (plain)
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

# BOM releases four synoptic charts per day.
# They are named according to the UTC dat/time for which they are valid.
#
# Filenames follow this template: IDY00030.YYYYMMDDHHMM.[png|pdf]
#
# IDY00030 = the asset name (i.e. the Mean Sea Level Pressure synoptic chart)
# .
# <datetime string>
# .
# <extension>  (I want pdf because it contains a Scalable Vectort Graphic (SVG) image)


# This function returns the filename for the most recent chart.

DeriveTime() {
    nowDate=$(\date -u +%Y%m%d)   # backslash req. to unalias date to raw format
    nowTime=$(\date -u +%H%M)     # (I have date aliased to date -R)
#    echo $nowDate$nowTime

    if [ $nowTime -ge 1800 ] ; then
        fileTime=1800
    elif [ $nowTime -ge 1200 ] ; then
        fileTime=1200
    elif [ $nowTime -ge 0600 ] ; then
        fileTime=0600
    else
        fileTime=0000
    fi

    echo $nowDate$fileTime
}