Skip to content

Commit

Permalink
Add notation of datetime/timespan in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
suconbu committed Sep 26, 2020
1 parent e38f09e commit 65bf7a3
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Dentacs/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.2.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
140 changes: 105 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,27 @@ It's developing with WPF and C# .NET Framework 4.7.2.
Executable binaries are available:
https://github.com/suconbu/dentacs/releases

Demo:
## Table of contents

* [Demo](#Demo) | [Features](#Features)
* [Shortcut keys](#Shortcut-keys)
* [Numbers](#Numbers) | [DateTime/TimeSpan](#DateTime/TimeSpan)
* [Operators](#Operators)
* [Variables](#Variables) | [Functions](#Functions) | [Constants](#Constants)
* [Reserved keywords](#Reserved-keywords)
* [License](#License)

## Demo

![screenshot](image/demo1.gif)

Main features:
## Features

* Multiline expression editor
* Can be mix different radix numbers in a expression
* Display calculation result in 3 different radix numbers at once
* Character code information (CodePoint, UTF-16, UTF-8) is displayed in status bar
* Operation for datetime / timespan -> [Datetime/Timespan](#Datetime/Timespan)
* Operation for DateTime / TimeSpan -> [DateTime/TimeSpan](#DateTime/TimeSpan)

## Shortcut keys

Expand Down Expand Up @@ -47,38 +58,82 @@ Hexadecimal | 0x04d2, 0x4D2
Octal | 0o2322
Binary | 0b0000010011010010

## Datetime/Timespan
## DateTime/TimeSpan

DateTime and TimeSpan can be represented by a quoted string.
Double quotes (`"`) or single quotes (`'`) can be used as the quotation mark.

Term | Definition | Example
---------|------------------------------------|------------------
Datetime | Represents a point on the timeline | `'2001/4/1 12:00'`, `'4/1'`
Timespan | Represents the length of time | `'15:00'`, `'10h300m'`
Type | Definition
---------|-----------------------------------
DateTime | Represents a point on the timeline
TimeSpan | Represents the length of time

```
Timeline
----------x----------x============x---------->
^ <--Timespan-->
Datetime
----------x----------x============x----------> Passage of time
^ ---TimeSpan-->
DateTime
```

Supported operations:
### Notation

#### DateTime

Style | Input | Result | Note
-----------------------|-----------------------|-----------------------|---------------------
General (yyyy/m/d) | '2019/8/18 7:36:13' | '2019/08/18 07:36:13' |
| | '2019/8/18 7:36' | '2019/08/18 07:36:00' |
| | '2019/8/18 7' | '2019/08/18 07:00:00' |
| | '2019/8/18' | '2019/08/18 00:00:00' |
| | '2019/8' | '2019/08/01 00:00:00' |
General (Year omitted) | '08/18 7:36:13' | '2020/08/18 07:36:13' | Use the current year
| | '08/18 7:36' | '2020/08/18 07:36:00' |
| | '08/18 7' | '2020/08/18 07:00:00' |
| | '08/18' | '2020/08/18 00:00:00' |
General (Date omitted) | '7:36:13' | '2020/04/01 07:36:13' | Use the current date
| | '7:36' | '2020/04/01 07:36:13' |
Standard (basic) | '20190818T073613' | '2019/08/18 07:36:13' |
| | '20190818T0736' | '2020/04/01 07:36:00' |
| | '20190818T07' | '2020/04/01 07:00:00' |
Standard (extended) | '2019-08-18T07:36:13' | '2019/08/18 07:36:13' |
| | '2019-08-18T07:36' | '2019/08/18 07:36:00' |
| | '2019-08-18T07' | '2019/08/18 07:00:00' |
| | '2019-08-18' | '2019/08/18 00:00:00' |
| | '2019-08' | '2019/08/01 00:00:00' |
Week number | 'CW33.7/2019' | '2019/08/18 00:00:00' | CW01 is the week with the year's first Thursday in it
| | 'CW33.7' | '2020/08/16 00:00:00' | Use the current year
| | 'CW33' | '2020/08/10 00:00:00' |

#### TimeSpan

Style | Input | Result | Note
----------------|--------------------------------|-------------------|-------------------------------
Comma separated | '+7:36:13.123' | '+7:36:13.123' | Must start with a sign (+/-)
| | '-7:36:13' | '-07:36:13' |
| | '+7:36' | '+07:36:00' |
| | '+7:96' | '+08:36:00' | 96min. -> 1hour + 36min.
| | '+1d 7:36:13' | '+1d 07:36:13' |
Unit specified | '1w1d7h36m13s123ms' | '+8d 7:36:13.123' |
| | '1week 1day 7hour 36min 13sec' | '+8d 7:36:13' | Can be insert a space
| | '1.5h 300sec' | '+01:35:00' | Can be specified fraction part

### Supported operations

Left hand side | Operation | Right hand side | Result
---------------|------------|-----------------|-------
Datetime | - | Datetime | Timespan
Datetime | +/- | Timespan | Datetime
Timespan | +/- | Timespan | Timespan
DateTime | - | DateTime | TimeSpan
DateTime | +/- | TimeSpan | DateTime
TimeSpan | +/- | TimeSpan | TimeSpan

Example of use:
```py
'2000/4/1 12:00' - '1999/4/1 12:00' # '366d 00:00:00'
'2000/4/1 12:00' + '15:00' # '2000/04/02 03:00:00'
'2000/4/1 12:00' + '+15:00' # '2000/04/02 03:00:00'
'4/1' + '40day' # '2020/05/11 00:00:00' (In 2020)
'15:00' - '300min' # '10:00:00'
'3day' - '10.5h' # '2d 13:30:00'
```

## Operators and precedence
## Operators

The followings the supported operators in dentacs, from highest to lowest precedence.

Expand Down Expand Up @@ -117,22 +172,37 @@ pi = 3 # OK: It is case sensitive

## Functions

Identifier | Parameters | Description
-----------|-------------|-----------------------------------------------------------------
trunc | (n) | Returns the integer part of a number by removing any fractional
floor | (n) | Returns the largest integer less than or equal to a given number
ceil | (n) | Returns the number of rounded up to the next largest integer
round | (n) | Returns the value of a number rounded to the nearest integer
sin | (d) | Returns the sine of a number of degrees
cos | (d) | Returns the cosine of a number of degrees
tan | (d) | Returns the tangent of a number of degrees
asin | (n) | Returns the arcsine (in degrees) of a number
acos | (n) | Returns the arccosine (in degrees) of a number
atan | (n) | Returns the arctangent (in degrees) of a number
atan2 | (y, x) | Returns the arctangent (in degrees) of a y and x (e.g. atan2(1, 1) -> 45)
log10 | (n) | Returns the base 10 logarithm of a number
log2 | (n) | Returns the base 2 logarithm of a number
log | (n[, base]) | Returns the natural logarithms or logarithm of a number with specified base (e.g. log(9, 3) -> 2)
### Arithmetic

Identifier | Parameters | Description | Examples
-----------|-------------|---------------------------------------------------------------------|--------------------
trunc | (n) | Returns the integer part of a number by removing any fractional | trunc(1.5) -> 1, trunc(-1.5) -> -1
floor | (n) | Returns the largest integer less than or equal to a given number | floor(1.5) -> 1, floor(-1.5) -> -2
ceil | (n) | Returns the number of rounded up to the next largest integer | ceil(1.5) -> 2, ceil(-1.5) -> -1
round | (n) | Returns the value of a number rounded to the nearest integer | round(1.5) -> 2, round(-1.5) -> -2
sin | (n) | Returns the sine of a number of degrees |
cos | (n) | Returns the cosine of a number of degrees |
tan | (n) | Returns the tangent of a number of degrees |
asin | (n) | Returns the arcsine (in degrees) of a number |
acos | (n) | Returns the arccosine (in degrees) of a number |
atan | (n) | Returns the arctangent (in degrees) of a number |
atan2 | (n1, n2) | Returns the arctangent (in degrees) of a y (n2) and x (n1) | atan2(1, 1) -> 45)
log10 | (n) | Returns the base 10 logarithm of a number | log10(1000) -> 3
log2 | (n) | Returns the base 2 logarithm of a number | log2(256) -> 8
log | (n1, n2) | Returns the natural logarithms or logarithm of a number (n1) with specified base (n2) | log(9, 3) -> 2)

### DateTime/TimeSpan

Identifier | Parameters | Description | Examples
-----------|-------------|------------------------------------------------------|---------------------------------
dayofweek | (datetime) | Returns day of week in a DateTime | dayofweek('2019/08/18') -> 'sun'
today | () | Returns DateTime of the beginning of the current day | today() -> '2020/04/01 00:00:00'
now | () | Returns DateTime of the current time | now() -> '2020/04/01 07:36:13'
seconds | (timespan) | Returns total seconds of TimeSpan | seconds('+01:01:01') -> 3661
minutes | (timespan) | Returns total minutes of TimeSpan | minutes('+01:01:01') -> 61.016...
hours | (timespan) | Returns total hours of TimeSpan | hours('+01:01:01') -> 1.01694...
days | (timespan) | Returns total days of TimeSpan | days('+36:00:00') -> 1.5
weeks | (timespan) | Returns total weeks of TimeSpan | weeks('+3d 12:01:01') -> 0.5

## Constants

Expand All @@ -141,7 +211,7 @@ Identifier | Description
PI | The ratio of the circumference of a circle to its diameter (3.141...)
E | The base of natural logarithms (2.718...)

## Keywords
## Reserved keywords

The following identifiers are reserved words and cannot be used as variable names.

Expand Down

0 comments on commit 65bf7a3

Please sign in to comment.