Skip to content

Instantly share code, notes, and snippets.

@Flayed
Created April 12, 2018 19:59
Show Gist options
  • Select an option

  • Save Flayed/0b0a7e3cdb95814ed2bf6c3bf48e9e1b to your computer and use it in GitHub Desktop.

Select an option

Save Flayed/0b0a7e3cdb95814ed2bf6c3bf48e9e1b to your computer and use it in GitHub Desktop.

Revisions

  1. Flayed created this gist Apr 12, 2018.
    25 changes: 25 additions & 0 deletions DayOfWeek.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    public enum DayOfWeek
    {
    Sunday = 0,
    Monday = 1,
    Tuesday = 2,
    Wednesday = 3,
    Thursday = 4,
    Friday = 5,
    Saturday = 6
    }

    private byte PackedDays { get; set; }

    public DayOfWeek StartDay
    {
    get { return (DayOfWeek)(PackedDays & 15); }
    set { PackedDays |= (byte)value; }
    }

    [BsonIgnore]
    public DayOfWeek EndDay
    {
    get { return (DayOfWeek)(PackedDays >> 4); }
    set { PackedDays |= (byte)((byte)value << 4); }
    }