Created
August 10, 2013 14:00
-
-
Save cleytonferrari/6200551 to your computer and use it in GitHub Desktop.
Algumas funções pra trabalhar com datas
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
DateTime baseDate = DateTime.Today; | |
var today = baseDate; | |
var yesterday = baseDate.AddDays(-1); | |
var thisWeekStart = baseDate.AddDays(-(int)baseDate.DayOfWeek); | |
var thisWeekEnd = thisWeekStart.AddDays(7).AddSeconds(-1); | |
var lastWeekStart = thisWeekStart.AddDays(-7); | |
var lastWeekEnd = thisWeekStart.AddSeconds(-1); | |
var thisMonthStart = baseDate.AddDays(1 - baseDate.Day); | |
var thisMonthEnd = thisMonthStart.AddMonths(1).AddSeconds(-1); | |
var lastMonthStart = thisMonthStart.AddMonths(-1); | |
var lastMonthEnd = thisMonthStart.AddSeconds(-1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment