Thanks Mike, I will check that out!
I may have found another solution this afternoon too. Since the user puts
in the week start date I think I might be able to use datedelta to the week
start date so that Tuesday would be the week start date + deltadate (1),
Wednesday would be the week start date + deltadate (2) and so on. Still
need to check if this does what I'm thinking it will though. I'll check out
baklabel too


On Sun, May 13, 2018, 6:47 PM Mike Dewhirst <[email protected]> wrote:

> On 13/05/2018 5:00 AM, Alexander Joseph wrote:
> > I'm building a timesheet app for employees and would like the
> > employees to be able to select a day of the week date based on what
> > the date was on Monday.
> >
> > ie. the user inputs the Monday date of the timesheet, then for each
> > row they need to fill out they can select the Day/Date for each day
> > that week so that those hours they input get assigned to that specific
> > day/date. The easiest way I can think of would be to make a list of
> > choices in the Model such as ...
> >
> > |
> > MONDAY = 'MO'
> > TUESDAY = 'TU'
> > WEDNESDAY = 'WE'
> > THURSDAY = 'TH'
> > FRIDAY = 'FR'
> > SATURDAY = 'SA'
> > SUNDAY = 'SU'
> >
> > DAY_CHOICES = (
> >     (MONDAY, 'Monday'),
> >     (TUESDAY, 'Tuesday'),
> >     (WEDNESDAY, 'Wednesday'),
> > (THURSDAY, 'Thursday'),
> > (FRIDAY, 'Friday'),
> > (SATURDAY, 'Saturday'),
> > (SUNDAY, 'Sunday'),
> > )
> > day = models.CharField(
> >     max_length=2,
> > choices=DAY_CHOICES,
> >     default=MONDAY,
> > )
> > |
> >
> > This would work except I also want to include the actual date of the
> > day they select, based on the Monday date that they put in in another
> > Model
> >
> > Is there a library or package I can use to do this?
>
> Not sure. Have a look at baklabel, a utility I wrote many years ago and
> while I use it every day I haven't looked at it in living memory. Source
> is at https://pypi.org/project/baklabel/#files
>
> It takes a date and returns a string being 'mon', tue' and so on except
> 'fri1', 'fri2' etc and it also cares about end-of-month and end-of-year.
> The string is intended as a path fragment for labelling scripted backups.
>
> The settings/options will allow a much more vanilla return string. You
> could stop it counting fridays and omit end-of-month and end-of-year
> detection.
>
> The date arithmetic in there might be useful and extractable as separate
> library.
>
> >
> > Thanks!
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to [email protected]
> > <mailto:[email protected]>.
> > To post to this group, send email to [email protected]
> > <mailto:[email protected]>.
> > Visit this group at https://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/django-users/6089eafa-7495-4ec4-a539-624cf95014b0%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/django-users/6089eafa-7495-4ec4-a539-624cf95014b0%40googlegroups.com?utm_medium=email&utm_source=footer
> >.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/cK-iY8YW6l8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/74e0e602-858e-85ad-3e87-8c69577d0ba9%40dewhirst.com.au
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGJrYjYg%2BqT_Xsz%2Ba-QKCy-6Fat88N-fch-E_9F9oovp7yusXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to