Skip to content

Short textual representation of the TimeSpan #3

@ExM

Description

@ExM

Short textual representation of the TimeSpan

  • D,d - day
  • H,h - hour
  • M,m - minute
  • S,s - second

For example:
With configuration class:

class Conf
{
	public TimeSpan Delay;
}

Section

<Conf Delay='1.5d' />

Parsed to

settings.Get<Conf>("Conf").Delay == TimeSpan.FromDays(1.5)

Section

<Conf Delay='80H' />

Parsed to

settings.Get<Conf>("Conf").Delay == TimeSpan.FromHours(80)

Section

<Conf Delay='600s' />

Parsed to

settings.Get<Conf>("Conf").Delay == TimeSpan.FromSeconds(600)

This is samples of valid strings:

  • -3d
  • 3.4d
  • 3h30m
  • 24h5s
  • -72.5d8s
  • -72.5d30.4h500m8s
  • -72.5D30.4h500M8s

and invalid strings:

  • -3p
  • 3.4d8d
  • 30m3h
  • 24h-5s
  • -72.5d8.s
  • .5d

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions