1+ const core = require ( '@actions/core' ) ;
2+ const github = require ( '@actions/github' ) ;
3+
4+ const dayjs = require ( 'dayjs' ) ;
5+ const dayjsPluginUTC = require ( 'dayjs/plugin/utc' )
6+
7+ dayjs . extend ( dayjsPluginUTC )
8+
9+ async function main ( ) {
10+ try {
11+ if ( core . getInput ( 'format' ) !== '' ) {
12+ manageTime ( ) ;
13+ }
14+ if ( core . getInput ( 'string' ) !== '' ) {
15+ manageString ( ) ;
16+ }
17+
18+
19+
20+ } catch ( error ) {
21+ core . setFailed ( error . message ) ;
22+ }
23+ }
24+
25+ main ( ) ;
26+
27+
28+
29+ function manageTime ( ) {
30+ const timezone = core . getInput ( 'timeZone' ) ; // default: 0
31+ const formatStr = core . getInput ( 'format' ) ; // default: ''
32+ console . log ( 'time zone: ' , timezone )
33+ console . log ( 'time format: ' , formatStr )
34+ const str = dayjs ( ) . utcOffset ( timezone ) . format ( formatStr )
35+ console . log ( "time formatStr: " , str )
36+
37+ core . setOutput ( "time" , str ) ;
38+ }
39+
40+ function manageString ( ) {
41+ const inputStr = core . getInput ( 'string' ) ;
42+ console . log ( `Manipulating string: ${ inputStr } ` ) ;
43+
44+ const lowercase = inputStr . toLowerCase ( ) ;
45+ console . log ( `lowercase: ${ lowercase } ` ) ;
46+ core . setOutput ( "lowercase" , lowercase ) ;
47+
48+ const uppercase = inputStr . toUpperCase ( ) ;
49+ console . log ( `uppercase: ${ uppercase } ` ) ;
50+ core . setOutput ( "uppercase" , uppercase ) ;
51+
52+ const capitalized = inputStr . charAt ( 0 ) . toUpperCase ( ) + inputStr . slice ( 1 ) . toLowerCase ( ) ;
53+ console . log ( `capitalized: ${ capitalized } ` ) ;
54+ core . setOutput ( "capitalized" , capitalized ) ;
55+ }
0 commit comments