-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(): Adds expression for adding/subtracting seconds, minutes and h…
…ours to timestamps
- Loading branch information
Showing
16 changed files
with
162 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ import './variant'; | |
import './string'; | ||
import './address'; | ||
import './ticket'; | ||
import './timestamp'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Blockly from 'blockly'; | ||
import type { Block } from 'src/typings/blockly'; | ||
import type { IExpression } from '@tezwell/smartts-sdk/typings/expression'; | ||
|
||
import BlockKind from '../../enums/BlockKind'; | ||
import SmartML from '../../generators/SmartML'; | ||
import { AddHours } from '@tezwell/smartts-sdk'; | ||
import { buildErrorInfo } from 'src/blocks/utils/errorHandling'; | ||
|
||
Blockly.Blocks[BlockKind.add_hours] = { | ||
init: function () { | ||
this.appendValueInput('HOURS').setCheck(['Int', 'Expression']).appendField('Add hours'); | ||
this.appendValueInput('TIMESTAMP').setCheck(['Timescript', 'Expression']).appendField('to timestamp'); | ||
|
||
this.setInputsInline(true); | ||
this.setOutput(true, ['Expression']); | ||
|
||
this.setTooltip(`Add seconds to timestamp.\n-\n(TTimestamp(), TInt()) => TTimestamp()\n`); | ||
|
||
this.setColour(200); | ||
this.setPreviousStatement(false); | ||
this.setNextStatement(false); | ||
}, | ||
}; | ||
|
||
SmartML.addBlock(BlockKind.add_hours, { | ||
toValue: (block: Block) => { | ||
const timestamp: IExpression<any> = SmartML.toValue(block, 'TIMESTAMP'); | ||
const hours: IExpression<any> = SmartML.toValue(block, 'HOURS'); | ||
return AddHours(timestamp, hours, buildErrorInfo(block)); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Blockly from 'blockly'; | ||
import type { Block } from 'src/typings/blockly'; | ||
import type { IExpression } from '@tezwell/smartts-sdk/typings/expression'; | ||
|
||
import BlockKind from '../../enums/BlockKind'; | ||
import SmartML from '../../generators/SmartML'; | ||
import { AddMinutes } from '@tezwell/smartts-sdk'; | ||
import { buildErrorInfo } from 'src/blocks/utils/errorHandling'; | ||
|
||
Blockly.Blocks[BlockKind.add_minutes] = { | ||
init: function () { | ||
this.appendValueInput('MINUTES').setCheck(['Int', 'Expression']).appendField('Add minutes'); | ||
this.appendValueInput('TIMESTAMP').setCheck(['Timescript', 'Expression']).appendField('to timestamp'); | ||
|
||
this.setInputsInline(true); | ||
this.setOutput(true, ['Expression']); | ||
|
||
this.setTooltip(`Add seconds to timestamp.\n-\n(TTimestamp(), TInt()) => TTimestamp()\n`); | ||
|
||
this.setColour(200); | ||
this.setPreviousStatement(false); | ||
this.setNextStatement(false); | ||
}, | ||
}; | ||
|
||
SmartML.addBlock(BlockKind.add_minutes, { | ||
toValue: (block: Block) => { | ||
const timestamp: IExpression<any> = SmartML.toValue(block, 'TIMESTAMP'); | ||
const minutes: IExpression<any> = SmartML.toValue(block, 'MINUTES'); | ||
return AddMinutes(timestamp, minutes, buildErrorInfo(block)); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Blockly from 'blockly'; | ||
import type { Block } from 'src/typings/blockly'; | ||
import type { IExpression } from '@tezwell/smartts-sdk/typings/expression'; | ||
|
||
import BlockKind from '../../enums/BlockKind'; | ||
import SmartML from '../../generators/SmartML'; | ||
import { AddSeconds } from '@tezwell/smartts-sdk'; | ||
import { buildErrorInfo } from 'src/blocks/utils/errorHandling'; | ||
|
||
Blockly.Blocks[BlockKind.add_seconds] = { | ||
init: function () { | ||
this.appendValueInput('SECONDS').setCheck(['Int', 'Expression']).appendField('Add seconds'); | ||
this.appendValueInput('TIMESTAMP').setCheck(['Timescript', 'Expression']).appendField('to timestamp'); | ||
|
||
this.setInputsInline(true); | ||
this.setOutput(true, ['Expression']); | ||
|
||
this.setTooltip(`Add seconds to timestamp.\n-\n(TTimestamp(), TInt()) => TTimestamp()\n`); | ||
|
||
this.setColour(200); | ||
this.setPreviousStatement(false); | ||
this.setNextStatement(false); | ||
}, | ||
}; | ||
|
||
SmartML.addBlock(BlockKind.add_seconds, { | ||
toValue: (block: Block) => { | ||
const timestamp: IExpression<any> = SmartML.toValue(block, 'TIMESTAMP'); | ||
const seconds: IExpression<any> = SmartML.toValue(block, 'SECONDS'); | ||
return AddSeconds(timestamp, seconds, buildErrorInfo(block)); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './add_seconds'; | ||
import './add_minutes'; | ||
import './add_hours'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
|
||
import BlockKind from 'src/blocks/enums/BlockKind'; | ||
import Block from 'src/components/blockly/Block'; | ||
import Shadow from '../../Shadow'; | ||
import Value from '../../Value'; | ||
|
||
export const AddSeconds = () => ( | ||
<Block type={BlockKind.add_seconds} tags={['expression', 'timestamp', 'add', 'seconds']}> | ||
<Value name="SECONDS"> | ||
<Shadow type={BlockKind.int_literal} /> | ||
</Value> | ||
</Block> | ||
); | ||
|
||
export const AddMinutes = () => ( | ||
<Block type={BlockKind.add_minutes} tags={['expression', 'timestamp', 'add', 'minutes']}> | ||
<Value name="MINUTES"> | ||
<Shadow type={BlockKind.int_literal} /> | ||
</Value> | ||
</Block> | ||
); | ||
|
||
export const AddHours = () => ( | ||
<Block type={BlockKind.add_hours} tags={['expression', 'timestamp', 'add', 'hours']}> | ||
<Value name="HOURS"> | ||
<Shadow type={BlockKind.int_literal} /> | ||
</Value> | ||
</Block> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters